Shiyan7/kinomore

Use `params` from rtk-query

DmitryScaletta opened this issue · 1 comments

You can rewrite this code

getFilmById: build.query<IMovie, string | string[] | undefined>({
query: id => `/movie?search=${id}&field=id&token=${API_KEY}`
}),

using params from rtk-query

getFilmById: build.query<IMovie, string | string[] | undefined>({ 
  query: id => {
    url: '/movie',
    params: {
      search: id,
      field: 'id',
      token: API_KEY,
    },
  },
}),

Documentation: https://redux-toolkit.js.org/rtk-query/api/fetchBaseQuery#setting-the-query-string

апи так не умеет. search=sometext&field=someField - такой запрос повторяется много раз