# Rawg api: getting 404

**URL:** <https://forum.codewithmosh.com/t/rawg-api-getting-404/18961>\
**Category:** React\
**Created:** [March 19, 2023, 9:59pm UTC](https://forum.codewithmosh.com/t/rawg-api-getting-404/18961 "2023-03-19T21:59:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ywapom](https://avatars.discourse-cdn.com/v4/letter/y/f4b2a3/32.png) [@Ywapom](https://forum.codewithmosh.com/u/Ywapom)\
**Post date:** [March 19, 2023, 9:59pm UTC](https://forum.codewithmosh.com/t/rawg-api-getting-404/18961/1 "2023-03-19T21:59:16Z")

</div>

**I am not getting the rawg movie data showing up.**  
as per the new React course I am using the `baseURL: 'https://api.rawg.io/api'`  
and then

```auto
useEffect(() => {
    apiClient
      .get<FetchGamesResponse>("/games")

```

in chrome tools I see: (I x’d out my key)  
`http://localhost:5173/games?baseURL=https://api.rawg.io/api&key=xxxxx`

If I go to:  
[https://api.rawg.io/api/games?key=xxxx](https://api.rawg.io/api/games?key=xxxx) it works  
[https://api.rawg.io/api/games&key=xxxx](https://api.rawg.io/api/games&key=xxxx) is 404

Not sure whats going on here. Any help?

---

<div class="post-metadata">

**Author:** ![JerryHobby](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/jerryhobby/32/5370_2.png) [@JerryHobby](https://forum.codewithmosh.com/u/JerryHobby)\
**Post date:** [March 28, 2023, 3:26pm UTC](https://forum.codewithmosh.com/t/rawg-api-getting-404/18961/2 "2023-03-28T15:26:32Z")

</div>

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

```auto
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.

```auto
      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](http://api.rawg.io/api/games?key=xxxx) it works  
> [api.rawg.io/api/games&key=xxxx](http://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

---

<div class="post-metadata">

**Author:** ![Jvrszk](https://avatars.discourse-cdn.com/v4/letter/j/dfb087/32.png) [@Jvrszk](https://forum.codewithmosh.com/u/Jvrszk)\
**Post date:** [April 20, 2023, 7:16am UTC](https://forum.codewithmosh.com/t/rawg-api-getting-404/18961/3 "2023-04-20T07:16:06Z")

</div>

Hey @Ywapom  
I was having the same issue as you and the error in my case was passing the **baseURL** inside the params object in the **api-client.ts** file.

```auto
export default axios.create({
  baseURL: 'https://api.rawg.io/api',
  params: {
    // I was passing the baseURL here before <<<
    key: '<YOUR_API_KEY>'
  }
})

```
