pradel / node-instagram

Instagram api client for node that support promises.
MIT License
190 stars 27 forks source link

await is a reserved word #8

Closed DavidRoca closed 7 years ago

DavidRoca commented 7 years ago

Hi, I am trying to use node-instagram but I am getting the error "await is a reserved word" with this in my code. If I remove "await" I'm getting a 400 code error (myId and myToken are the id and token from my instagram). Am I doing something wrong ? Thanks.

import Instagram from 'node-instagram';

// Create a new instance.
const instagram = new Instagram({
  clientId: 'myId',
  accessToken: 'myToken',
});

// You can use callbacks or promises
instagram.get('users/self', (err, data) => {
  console.log(data);
});

// Get information about the owner of the access_token.
const data = await instagram.get('users/self');
console.log(data);
pradel commented 7 years ago

Can you provide a snippet showing how you try to use this module?

penguoir commented 5 years ago

You cannot use await outside of a function. It must be in the scope of an async function. In this case, your best chance is to replace

const data = await instagram.get('users/self');
console.log(data);

with

instagram.get('users/self').then(data => {
  console.log(data);
}