Reputation: 461
I'm using axios and vue.js to play with the Fortnite Tracker API. In their documentation it's clearly said that we need to include the "TRN-Api-Key" in header.
I tested with Postman and It works.
And this is my axios function to make the request:
let url = `https://api.fortnitetracker.com/v1/profile/${this.platform}/${this.username}`;
// username and platform are from my Vue Component.
axios.get(url, {
headers: {
"TRN-Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxx" // of course from my account on their website.
}
})
.then(response => console.log(response.data))
I expect the output in json like in Postman but I had a 404 Error: "Network Error".
And in the Browser Network Debug I can't see the request header 'TRN-Api-Key'.
[EDIT]
Upvotes: 0
Views: 246
Reputation: 4163
If your app is running on a server you can write a short PHP
-Script and use curl
in it to access the API (I think it's even possible to generate PHP
code from Postman).
Just address this script with axios and submit your platform
and username
properties to build the right url.
Or have a look at this post alternatively. Maybe the use of an other API like @kecinotrab provided in the acceptet answer will help you too.
Upvotes: 1