Q:

Curl -u Request in javascript

I need to perform a curl request like this:
curl -u "apikey:{apikey}" "{url}"

How can i do this in javascript? In particular i have some trouble to handle the -u curl field into javascript request. 

A:

You will have to specify a basic auth header (Authorization: Basic <base64 of apikey:value>) with the API key when using JavaScript. If you are using XMLHttpRequest, have a look at this this: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/setRequestHeader

