createCompany: build.mutation<ICompany, ICompany>({
query: (company) => ({
url: `/companies`,
method: 'POST',
body: company
}),
//подгрузка актуальных тэгов после изменения
invalidatesTags: ['Post']
}),
только options ? покажи нетворк
ТОлько OPRIONS OPTIONS /companies HTTP/1.1 Host: 4e88-91-210-24-198.ngrok.io User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 Accept: */* Accept-Encoding: gzip, deflate, br Accept-Language: ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7 Access-Control-Request-Headers: content-type Access-Control-Request-Method: POST Origin: http://localhost:3000 Referer: http://localhost:3000/ Sec-Fetch-Dest: empty Sec-Fetch-Mode: cors Sec-Fetch-Site: cross-site X-Forwarded-For: 91.210.24.198 X-Forwarded-Proto: https HTTP/1.1 200 OK Access-Control-Allow-Headers: Content-Type Access-Control-Allow-Methods: POST Access-Control-Allow-Origin: http://localhost:3000 Access-Control-Max-Age: 300 Vary: Origin Vary: Access-Control-Request-Method Vary: Access-Control-Request-Headers Date: Sat, 14 May 2022 09:51:38 GMT Content-Length: 0 cors настроен на options тоже
так покажи все
export const companyAPI = createApi({ reducerPath: 'companyAPI', baseQuery: fetchBaseQuery({baseUrl: 'http://localhost:5151'}), tagTypes: ['Post'], endpoints: (build) => ({ fetchAllCompany: build.query<ICompany[], number>({ query: (limit: number = 5) => ({ url: `/companies`, params: { _limit: limit } }), //подгрузка актуальных тэгов после изменения providesTags: result => ['Post'] }), createCompany: build.mutation<ICompany, ICompany>({ query: (company) => ({ url: `/companies`, method: 'POST', body: company }), //подгрузка актуальных тэгов после изменения invalidatesTags: ['Post'] }), updateCompany: build.mutation<ICompany, ICompany>({ query: (company) => ({ url: `/companies/${company.id}`, method: 'PUT', body: company }), //подгрузка актуальных тэгов после изменения invalidatesTags: ['Post'] }), deleteCompany: build.mutation<ICompany, ICompany>({ query: (company) => ({ url: `/companies/${company.id}`, method: 'DELETE', }), //подгрузка актуальных тэгов после изменения invalidatesTags: ['Post'] }), }) })
Обсуждают сегодня