I am writing an app with React Native for IOS device, with Django server (Python). I saw that this question was asked many times - but non of the answers worked for me, so maybe someone can help.
This is my code:
let url = base_url + eventManager(id);
let request = {
method: "GET",
headers: {
"Content-Type": "application/json",
Authorization: `Token ${token}`,
},
};
await fetch(url, request, { timeout: 2000 })
.then(async (res) => {
const data = await res.json();
....
}
I got an warning 'JSON Parse error: Unrecognized token '<'' I already tried
- replacing res.json() with res.text()
- removing content-type header
- removing the timeout argument
- change the handle promise like that:
.then(res => res.json()) .then(resJson => { ... }
Any suggestions?
Thanks
res.text(): Promise { "_U": 0, "_V": 0, "_W": null, "_X": null, }
That is the log of res.text() - what should I do?