mvdb mvdb - 9 months ago 33
iOS Question

fetch() doing GET instead of POST on react-native (iOS)

I have the following code in my component:

fetch('', {
method: 'POST',
headers: {'Accept': 'application/json', 'Content-Type': 'application/json'},
body: JSON.stringify({
key: 'value'
then((response) => {
console.log('Done', response);

And every time the request is a GET (checked server logs). I thought it was something to do with
(but apparently no such thing in
) and ATS (but already turned off by default, plus my domain is HTTPS). I've tried from a browser and from a
and it worked perfectly, so a priori no issue on server configuration. Any idea what's going on here?

I'm using the latest


After further digging, it was definitely an issue with the API + fetch. I was missing a slash at the end of the URL and the API issued a 301, that fetch didn't handle correctly. So I don't know if there is something to fix in the fetch function (and underlying mechanisms) but this fixed my issue :)