axios.post(`https://id.twitch.tv/oauth2/token?client_id=${clientid}&client_secret=${clientsecret}&grant_type=client_credentials`).then(response => {
accessToken = response.data.access_token;
console.log(accessToken)
})
let api = axios.create({
headers: {
'Client-ID': `${clientid}`,
'Authorization': `Bearer ${accessToken}`
}
})
I think it is good but I have an error :
0|main | TypeError [ERR_INVALID_ARG_TYPE]: The "url" argument must be of type string. Received function wrap
0|main | at validateString (internal/validators.js:124:11)
0|main | at Url.parse (url.js:159:3)
0|main | at urlParse (url.js:154:13)
0|main | at /root/node_modules/snekfetch/src/node/index.js:25:28
0|main | at new Promise (<anonymous>)
0|main | at Object.request (/root/node_modules/snekfetch/src/node/index.js:24:10)
0|main | at Snekfetch.then (/root/node_modules/snekfetch/src/index.js:147:39)
0|main | at Object.<anonymous> (/root/main.js:62:22)
0|main | at Module._compile (internal/modules/cjs/loader.js:1063:30)
0|main | at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
0|main | at Module.load (internal/modules/cjs/loader.js:928:32)
0|main | at Function.Module._load (internal/modules/cjs/loader.js:769:14)
0|main | at Object.<anonymous> (/usr/lib/node_modules/pm2/lib/ProcessContainerFork.js:33:23)
0|main | at Module._compile (internal/modules/cjs/loader.js:1063:30)
0|main | at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
0|main | at Module.load (internal/modules/cjs/loader.js:928:32) {
0|main | code: 'ERR_INVALID_ARG_TYPE'
0|main | }