#Can you make multiple requests in one loader?
1 messages · Page 1 of 1 (latest)
Just curious if im able to make multiple fetch requests, I then need to figure how I am can retrieve the logged in users id from Remix-Auth because its needed in a fetch request
You can await the user id from remix-auth and then make your fetch
You can make as many requests as you want inside a loader (as I understand it). I like to think of the loader as just "code that the server should run before the pages loads for the user", so you can kinda put whatever (and however much) you want inside there
yea it's like a "normal" API endpoint, just embedded in your route file
Just quickly trying something, while this is not erroring out its out putting {size: 0} not what the response should be, I'm assuming it's just the way I've done it
What should bits look like instead?
"data": [
{
"user_id": "158010205",
"user_login": "tundracowboy",
"user_name": "TundraCowboy",
"rank": 1,
"score": 12543
},
{
"user_id": "7168163",
"user_login": "topramens",
"user_name": "Topramens",
"rank": 2,
"score": 6900
}
],
"date_range": {
"started_at": "2018-02-05T08:00:00Z",
"ended_at": "2018-02-12T08:00:00Z"
},
"total": 2
}``` or atleast be null
I would try and use a service like Postman to double check the output of the API request first
Rather than doing it in Remix
If you query that Twitch API and look at what it returns (make sure to do the auth stuff) that'll help you first figure out if it's a Remix problem or an API problem
Tried the exact same request in postman and got the required output, If I console log the json output of the fetch in the loader I can see the whole response but nothing actually resembling the right response
I've managed to get a bit further now I can see the bits request results in a 200 ok, but again there is nothing resembling what the response should be
I am going to open a new question for this