13 lines
435 B
JavaScript
13 lines
435 B
JavaScript
const axios = require('axios')
|
|
|
|
module.exports = getUserInfo = (async (client_id, access_token, type) => {
|
|
return await axios.get('https://api.twitch.tv/helix/users', {
|
|
headers: {
|
|
'Authorization': `Bearer ${access_token}`,
|
|
'Client-Id': client_id
|
|
}
|
|
}).then(response => {
|
|
if (type === 'login') return response.data.data[0].login
|
|
if (type === 'id') return response.data.data[0].id
|
|
}).catch(console.error())
|
|
}) |