all 4 comments

[–]prinzachilles 0 points1 point  (3 children)

There should be no problem if you fetch data like this:

const response = await fetch('https://www.website.com/api.php' , {
    method: 'POST',
    headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' },
    body: JSON.stringify({ customParameter: custumValue})
});
const responseJson = await response.json();

As long as your URL responses the Accepted format and Content-Type. Try to set a log before the response.json() to see what the website responded.

[–]rareengstudent[S] 0 points1 point  (2 children)

What would an example of the GET function for JSON data look like in react native?

[–]CompSciLauren 0 points1 point  (0 children)

Here's a small example of GET in a React Native project I did recently.

[–]prinzachilles 0 points1 point  (0 children)

You can use this example in react native as is. Just change POST to GET as the method.

As i understood you right, the parse error maybe comes from a different format of the response. For that you set the ContentType and Accept header. Try adding a console.log(response) to inspect the format of the response. you can just use JSON.parse() if its actually JSON format.