I want to call a REST API from JavaScript.
Here's what I've tried:
var mainURI = '<MyAPIURI>';
var mainURIEncoded = encodeURI(mainURI);
var mainRequest = new XMLHttpRequest()
mainRequest.open('GET', mainURIEncoded, true)
mainRequest.onload = function () {
var data = JSON.parse(this.response)
}
I get this error:
No HTTP resource was found that matches the request URI 'MyAPIURI(Cut off at '#')'
My URI has a '#' symbol in it and it seems like the problem is my mainURIEncoded
string is cut off at the '#'.
Any help appreciated.