Closed Mikescops closed 4 months ago
Sorry, don't bother, the userId is out of the JS integer space that is use by JSON.parse()
, this causes the final value to be inconsistent when stored in memory.
One solution would be to have the API return a string for the userId to avoid such scenario in most languages, but it can be solved on the client side too, so up to you.
Further reading for anyone stumbling upon this issue: https://jsoneditoronline.org/indepth/parse/why-does-json-parse-corrupt-large-numbers/
JSON.parse
is used in most modern request libraries like got
so make sure you parse the JSON manually instead.
Simplest solution here to replace the bigint into a string .replace(/([\[:])?(\d+)([,\}\]])/g, '$1"$2"$3');
Thanks for the report. We will look at potential solutions. Since changing the type of the user_id
field is considered a breaking change we will need some time, though.
In addition to the workaround of manually parsing the JSON, I can think about a couple more:
user_id
in the API request URLs with the keyword me
./me
request, which is returned as a string.We will implement the two solutions above soon in this sample app.
Thanks @pestevez, it wasn't crystal clear to me that me
would work for every endpoint, maybe this could be added to the documentation.
Hello,
I'm getting a strange behaviour when I'm calling
oauth/access_token
and then the graph API/me
.As you can see below the two IDs are different by 1.
The id returned by
/me
is the correct one as it allows me to fetch the other resources associated to the user, the one provided by authentication is wrong and doesn't work.Hope you can help on this one, thanks!