Reputation: 11
I am doing a project and hosting a website on Amazon Web Service using CodeStar and a node.js web application. I want to implement a simple public API from Nasa using javascript. In cloud9 it works fine but as soon as I push it to my master branch and the AWS pipeline has finished deploying it, my website does not want to make the API request and I get the error: "Missing authentication token"
Here is the code:
https.open("GET", "https://api.nasa.gov/planetary/apod?api_key=zuOehZm6hq1Rt9cufqw36ADo0kZT3mfq5dGmCPNo", false);
https.onreadystatechange = () => {
if(https.status == 200 && https.readyState == 4){
var vals = JSON.parse(https.response);
console.log(vals);
}else{
console.log(`error ${https.status} ${https.statusText}`);
}
}
https.send(null);
Upvotes: 1
Views: 59