I am using RTK Query mutation to update my entities. There is api-platform on the backend that accepts only "application/merge-patch+json" Content-Type with PATCH requests. If I try to put this in my mutation's return statement:
method: 'PATCH',
headers: {
"Content-Type": 'application/merge-patch+json'
},
I get only [object Object] in my request body instead of json. However, if i change my method to "PUT" or Content-Type to "application/json", my request body is as expected and contains valid json.
fetchBaseQuery
does not know that content-type by default. In that case instead of passing
body: something
from your query
,
you need to pass
body: JSON.stringify(something)