You will need to share your code before someone can show you where the issues are. In this case, you are showing:
localhost_5173/games**?baseURL**=https_api.rawg.io/api&key=xxxxx
That should not be that way. You are somehow passing baseURL as a parameter.
Here are the moving parts:
in apiClient.ts
import axios from "axios";
export default axios.create({
baseURL: "https://api.rawg.io/api",
params: {
key: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
},
});
Then, in useData.ts
Your call to ApiClient should look like this.
ApiClient.get<FetchResponse<T>>(endpoint, {
signal: controller.signal,
...requestConfig,
})
The second part of the question is regarding this:
api.rawg.io/api/games?key=xxxx it works
api.rawg.io/api/games&key=xxxx is 404
The format for get requests is: url?key1=value&key2=value
after the url is a ? — that means there are query parameters following
Then each parameter is concatenated with an &.
Therefore, your working example is correct. Has the ?. The second example is incorrect because there’s no ? after games.
This leads me to believe you’ve truncated the url that’s not working. And it probably had more stuff in the front. If that’s the case, then perhaps your baseURL was not formatted correctly.
Hard to say exactly. But if you sort through these things, you’ll find the problem. Remember, coding is 20% of the work. Debugging is 80%.
Jerry