Skip to content

Commit c77c3c5

Browse files
authored
Merge pull request #4236 from Faithfinder/patch-1
2 parents 8a73b7a + 19bdb1c commit c77c3c5

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

docs/tutorials/essentials/part-7-rtk-query-basics.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,14 @@ export const { useGetPostsQuery } = apiSlice
138138

139139
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.
140140

141+
:::tip
142+
143+
**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.
144+
145+
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!
146+
147+
:::
148+
141149
#### API Slice Parameters
142150

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

0 commit comments

Comments
 (0)