I'm using the Discord API and I want it to send the longitude and latitude of the ISS using the "where the ISS at" API, but if I try and pick an object out of the JSON it comes back empty.
if (message.content.startsWith(`${prefix} were is the iss`)) {
const https = require('https');
https.get('https://api.wheretheiss.at/v1/satellites/25544', (resp) => {
let data = '';
// A chunk of data has been recieved.
resp.on('data', (chunk) => {
data += chunk;
});
// The whole response has been received. Print out the result.
resp.on('end', () => {
console.log(JSON.parse(data).explanation);
const {
lattitude,
longitude
} = data;
console.log(lattitude)
console.log(longitude)
message.channel.send(`ok ${data}`)
});
}).on("error", (err) => {
console.log("Error: " + err.message);
})
}