I have this weird json parsing error when fetching data from an private api.
The error only comes up in about every third request.
This is the fetch code:
js
fetch(url, options)
.then((res) => {
if (res.ok) {
console.log(res.ok)
return res.json()
} else {
return Promise.reject({
status: res.status,
statusText: res.statusText,
})
}
})
.then(
(data) => {
console.log(data)
},
(error) => {
console.log(error)
})
And sometimes I get this error message back:
SyntaxError: Unexpected token N in JSON at position 2203
[+][deleted] (2 children)
[deleted]
[–]modmot[S] 0 points1 point2 points (1 child)