From the course: TanStack Query: Efficient Data Fetching and State Management
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Sending a Q\query - TanStack Query Tutorial
From the course: TanStack Query: Efficient Data Fetching and State Management
Sending a Q\query
- [Instructor] Let's make some adjustments to our GitHub profile component so that we can start to make some requests of this data. So within the GitHub profile component, I'm going to call the use Query hook. This use Query hook is going to come from React Query. So let's go ahead and import it here at the top. Now this query is going to be responsible for fetching the data from this API. So within use query, we'll open and close a set of curly braces. We're going to assign a query key. The query key is going to be a unique identifier for this data, so we'll call it user. Then we'll go ahead and create a query function. This is going to be an asynchronous function that'll be responsible for fetching and returning some data. So that's going to look like a regular old fetch request, like you might've seen many times before. So we will say, response equals a weight, fetch, https, api.github.com/users, and then you can plug in your own GitHub name here, I'll just say, Eve Porcello at the…