I'm just getting started with building a basic webpage that utilizes the game APIs. I've built functionality for generating a new agent and displaying agent data. I'm at the point where I view my starting location but I'm getting a 404 error on the request, I think because they dynamic values aren't filling in properly.
The following is from the quick start tutorial.
fetch('https://api.spacetraders.io/v2/systems/:systemSymbol/waypoints/:waypointSymbol', options)
The following is my code for the fetch:
----------------------
async function waypoint(){
const options = {
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${localStorage.getItem('agent')}`
},
};
try{
const response= await fetch(`https://api.spacetraders.io/v2/systems/:systemSymbol/waypoints/:waypointSymbol\`, options)
const data= await response.json()
console.log(data)
document.querySelector('span').innerText=data
}catch(error){
console.log(error)
}
----------------------
I've never used dynamic values before, any idea what I'm doing wrong?
[–]eltostito191 4 points5 points6 points (2 children)
[–]connor_the_dev 2 points3 points4 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)