Skip to content

Commit

Permalink
Merge pull request #4236 from Faithfinder/patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
markerikson authored Dec 15, 2021
2 parents 8a73b7a + 19bdb1c commit c77c3c5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/tutorials/essentials/part-7-rtk-query-basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,14 @@ export const { useGetPostsQuery } = apiSlice

RTK Query's functionality is based on a single method, called `createApi`. All of the Redux Toolkit APIs we've seen so far are UI-agnostic, and could be used with _any_ UI layer. The RTK Query core logic is the same way. However, RTK Query also includes a React-specific version of `createApi`, and since we're using RTK and React together, we need to use that to take advantage of RTK's React integration. So, we import from `'@reduxjs/toolkit/query/react'` specifically.

:::tip

**Your application is expected to have only one `createApi` call in it**. This one API slice should contain _all_ endpoint definitions that talk to the same base URL. For example, endpoints `/api/posts` and `/api/users` are both fetching data from the same server, so they would go in the same API slice. If your app does fetch data from multiple servers, you can either specify full URLs in each endpoint, or if necessary create separate API slices for each server.

Endpoints are normally defined directly inside the `createApi` call. If you're looking to split up your endpoints between multiple files, see [the "Injecting Endpoints" section in Part 8](./part-8-rtk-query-advanced.md#injecting-endpoints) section of the docs!

:::

#### API Slice Parameters

When we call `createApi`, there are two fields that are required:
Expand Down

0 comments on commit c77c3c5

Please sign in to comment.