Improve fetchBaseQuery content json verification
See original GitHub issueCurrently in the docs regarding the body it says:
// fetchBaseQuery automatically adds 'content-type: application/json' to the Headers and calls JSON.stringify(patch)
However it doesn’t state that it only “stringifies” if the content-type
is strictly application/json
, I use application/vnd.api+json
for example and it was not very easy to figure what was wrong.
My proposal is to check if the content-type contains the json extension, so it will cover all json cases, if no one sees any issues with this proposal I’d be glad to push a PR for it, otherwise we could at least update the docs to avoid any confusion.
Issue Analytics
- State:
- Created a year ago
- Comments:9 (8 by maintainers)
Top Results From Across the Web
fetchBaseQuery - Redux Toolkit
The "json" and "text" values instruct fetchBaseQuery to the corresponding fetch response methods for reading the body. content-type will check ...
Read more >Validate, Query, and Change JSON Data with Built-in Functions
Validate, Query, and Change JSON Data with Built-in Functions (SQL Server)
Read more >Implementing RTK Query in a React Native App - Bionic Julia
... into how we might improve API querying throughout our React Native app. ... import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react' ...
Read more >Creating React Apps With Redux Toolkit and RTK Query - Toptal
This makes the developer experience better by allowing imports. ... baseQuery: fetchBaseQuery({ baseUrl: 'https://tp-auth.herokuapp.com', }) ...
Read more >Easy guide to JSON input validation in Rust web services
Better JSON validation. To improve the error, we'll use the serde_path_to_error crate, which, as the name suggests, converts the serde error ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@ShaunDychko @phryneas I ran into this recently with a custom fetch wrapper based around
fetchBaseQuery
, and added the solution as proposed here: https://github.com/reduxjs/redux-toolkit/pull/2331. I’d recommend we go with this approach as it’s a simple opt-in mechanism for JSON API users (like me, sometimes! 😂)This is handled in #2331 which I just merged into the 1.9 branch.