I am trying to get data from the ProBasketballAPI.com API. The docs state the following:
'To make calls to the ProBasketball API, you must make a POST request to the specified URL. In this request you must pass along your API key, and that is it. You now have access to the API!
Of course you can pass along arguments other than just your API key, in fact, it is encouraged that you do so. It will help narrow down data that will be returned.
All responses will be in the JSON format.'
I am trying to pass the api_key as an argument as it states like this.
const options = {
'api_key': JSON.stringify(api_key),
method: 'post',
headers: {
'Content-Type': 'application/json'
}
};
const x = fetch('https://probasketballapi.com/players', options);
x.then((response) => {
const data = response.json();
data.then((response) => {
console.log(response)
})
})
But I receive the following error from the api,
{ errors: [ 'The api key field is required.' ] }
I have read the documentation but I can not figure it out. The documentation can be found at https://probasketballapi.com/docs/authentication