jlobos / instagram-web-api

🤳 Instagram Private Web API client for Node
https://npmjs.com/instagram-web-api
MIT License
1.12k stars 189 forks source link

getUserByUsername() is getting error #286

Open erhancan256 opened 2 years ago

erhancan256 commented 2 years ago

hello i using instagram-web-api last version

i using getUserByUsername() method and i get this error (node:96495) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'user' of undefined how can i fix ?

adamwiw commented 2 years ago

I just started getting this message. It worked until I started blasting the api and running it over and over. Are you still getting the message? I don't know if they did something temporarily or I'm done.

  async getUserByUsername({ username }) {
    return this.request({
      uri: `/${username}/?__a=1`,
      headers: {
        referer: baseUrl + '/' + username + '/',
        'x-instagram-gis': await this._getGis(`/${username}/`)
      }
    }).then(data => data.graphql.user)
  }

When you debug into the then part you can see there's no data coming back. I can still access instagram through the web though so I wonder what they did.

S-codes14 commented 2 years ago

hello i using instagram-web-api last version

i using getUserByUsername() method and i get this error (node:96495) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'user' of undefined how can i fix ?

also got the same problem this ins my solution:

const Instagram = require('instagram-web-api')
const { username, password } = process.env

const client = new Instagram({ username, password })

;(async () => {
  await client.login()
  const instagram = await client.getUserByUsername({ username: 'instagram' })

  console.log(instagram)
})()

I just had to read the document properly