NodeJS - Get json with node-fetch

Ideally you should create an App access token and use it until it expires.

For example

Will generate a token and store it in Redis.

Your code above (node-fetch) can load the token from Redis and use it.

However you can do (not tested not sure of correct node-fetch syntax to send a form). This is not advised as it generates a token every time

const fetch = require('node-fetch')
fetch('https://id.twitch.tv/oauth2/token', {
    method: 'POST',
    body: {
        client_id: client_id,
        client_secret: client_secret,
        grant_type: "client_credentials"
    }
})
.then(res => res.json())
.then(res => {
    var token = resp.body.access_token

fetch('https://api.twitch.tv/helix/streams/', {
    method: 'GET',
    headers: {
        'Client-ID': yourID
        'Authorization': 'Bearer' + token
    }
})
 .then(res => res.json())
 .then(res => {
     console.log(res) // I keep getting "OAuth token is missing"
 });

});