I am new to using API's that have authentications, on the pivotal website they have commands using curl commands that look like this
export TOKEN='your Pivotal Tracker API token'
curl -X GET -H "X-TrackerToken: $TOKEN" "https://www.pivotaltracker.com/services/v5/projects/99"
I was wondering how I can convert this to JavaScript by making a request, the problem is I don't know where to put the token when making the request to an API.
So far in JavaScript I have this
function reqListener () {
console.log(this.responseText);
}
var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
var oReq = new XMLHttpRequest();
oReq.addEventListener("load", reqListener);
oReq.open("GET", "https://www.pivotaltracker.com/services/v5/projects/99?fields=version");
oReq.setRequestHeader(header, 'Pivotal token');
oReq.send();
Also i dont know what to in place of header.