S
S
ScorpionN2020-09-29 16:36:22
JavaScript
ScorpionN, 2020-09-29 16:36:22

One has an error, the other is fine, what's the problem?

I have fetch on a free hosting that takes data from php in json format, in general, the question is that everything works fine for me, and other users get this error: "Uncaught (in promise) syntaxerror unexpected token in json at position 0 ". It would be one thing if I also had it, but I even tried to lower the Internet to the very minimum, it took a long time to load, but all the data was given out, but other users get an error, what could be the problem? It’s just very strange that I don’t have a single error and everything is fine, while others have this error, although the input and output data are the same.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Robur, 2020-09-29
@Robur

unexpected token in json at position 0

happens when the server gives a non-json response. you need to somehow get a request log and a server response from other users, then it will be clear what is happening there. Or catch it on the server side

A
Alexander Kuznetsov, 2020-09-29
@GeFFest

Everything is like in that quote:

https://bash.im/quote/438821

Some of the possible reasons:
  • Users have an outdated version of the browser
  • Users have some kind of proxy that replaces the JSON response with some other one, changes the headers, due to which JSON is no longer correctly recognized
  • There is some kind of authorization on the site and you see it as an admin, and users see it as guests and instead of JSON they see some kind of error or authorization form
  • There is some kind of caching at the server level and users get the result from the cache, but you don't

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question