Itzik Ben Hutta Itzik Ben Hutta - 7 months ago 36
Javascript Question

jQuery AJAX not sending hashtag symbols which causes my request to fail

I have a problem. I'm working with Elixir Phoenix and React.JS. I have a Token that is used to verify the user. This Token also has hashtags in it so when I send a request to verify it, it is being sent without the hash symbols and what comes after them which makes my request to fail. How can I solve this issue? For some reason I don't have that problem when I use fetch with React Native, but here I do. I tried many variations as you can see in the image.
enter image description here

Answer

The hash and anything after it will not be sent by browsers in a request.
You should encode the token so that the hash is escaped.

fetch('http://localhost:4000/api/users/'+encodeURIComponent(accesstoken), {