question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Async Fetching Data w/ Props.params Query

See original GitHub issue

Say you have a component that just displays a single TopicItem (…/containers/topicItem.jsx), and you want to async fetch the data for that item [using a URL-Query from props.params.topicID] similarly to how it’s done in Vote.jsx:

   static need = [  // eslint-disable-line
      fetchTopics
    ]

How would you pass a query-ID to a similar “fetchTopic” to make the request like so?

export function fetchTopic(id) {
  return {
    type: types.GET_TOPIC,
    promise: makeTopicRequest('get', id)
  };
}

**Noticed that this same question has been asked a number of times and in several different places… Going to attempt to document a simple solution below, as none of the other discussions provide a clear cut answer as to how they “got it working.”

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
slavab89commented, Jul 23, 2016

Take a look at this issue as well https://github.com/choonkending/react-webpack-node/issues/268 because they talk there on the same thing i believe 😃

0reactions
slavab89commented, Oct 17, 2017

We’re cleaning up issues on the project and since this is an old issue we’re closing it. Moreover, the code has changed quite a lot since this issue was opened. If you still experience this or have an issue, please comment here or open a new one

Read more comments on GitHub >

github_iconTop Results From Across the Web

Data Fetching: getServerSideProps
Learn how to fetch data on each request with Next.js. ... export async function getServerSideProps(context) { return { props: {}, // will be...
Read more >
Async data made simple with React Query - Hey! I'm Tyler
The first parameter to useQuery is a string and this is how the hook knows what to cache when data is returned. You...
Read more >
Common data fetching patterns for real apps with react-query
Fetch data and handle results: useQueries . Fetch a subset of data using query strings or query params: useQuery with parameters.
Read more >
How to fetch with parameters using React Query?
So, in short: const getEvents(month) = async () => { const response = await axios.
Read more >
Data Fetching – Fetching Data - Intro to Next.js
There are many ways to fetch data with Next.js. Depending on when you need the data and what you're doing with it, you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found