Simplest API Request - No data?

Need help with your application? Ask here.
Post Reply
DaveTheGeek
Posts: 3
Joined: Sun Mar 24, 2019 3:21 am

Simplest API Request - No data?

Post by DaveTheGeek » Sun Mar 24, 2019 7:00 pm

Hi there,
I'm trying the utmost simplest API request - I'm simply trying to console.log the API response of '/Platforms'.

Here is the URL I'm hitting: https://api.thegamesdb.net/Platforms/?a ... VATE___KEY___

The response I'm getting is only the following without any platform data.
When using my private key:
{ remaining_monthly_allowance: 0,
extra_allowance: 5999,
allowance_refresh_timer: null }

and when using the public key:
{ remaining_monthly_allowance: 1498,
extra_allowance: 0,
allowance_refresh_timer: 2549259 }

I'm sure I'm missing something ridiculously simple.

Here is the code I'm attempting to run:

Code: Select all

const fetch = require("node-fetch");

module.exports = {
    getPlatforms
};

const API_URL = 'https://api.thegamesdb.net';
const API_KEY = '?apikey=___MY__PRIVATE___KEY___';

async function getPlatforms() {
    console.log(API_URL + '/Platforms' + '/' + API_KEY);
    fetch(API_URL + '/Platforms' + '/' + API_KEY)
        .then(res => res.json())
        .then(data => {
            console.log(data)
        })
        .catch(err => {
            console.log('error:', data)
        });
}

User avatar
Zer0xFF
Posts: 244
Joined: Fri Apr 20, 2018 9:18 am

Re: Simplest API Request - No data?

Post by Zer0xFF » Mon Mar 25, 2019 1:37 pm

the url should be ".../Platforms?blahblah=" without the last "/" you include
Regards
Zer0xFF

Post Reply