question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improve fetchBaseQuery content json verification

See original GitHub issue

Currently 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:closed
  • Created a year ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
msutkowskicommented, May 15, 2022

@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! 😂)

0reactions
phryneascommented, Jun 10, 2022

This is handled in #2331 which I just merged into the 1.9 branch.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found