instagram-web-api icon indicating copy to clipboard operation
instagram-web-api copied to clipboard

getUserByUsername() is getting error

Open erhancan256 opened this issue 2 years ago • 2 comments

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 ?

erhancan256 avatar Mar 19 '22 16:03 erhancan256

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.

adamwiw avatar Apr 15 '22 05:04 adamwiw

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

S-codes14 avatar Jun 01 '22 00:06 S-codes14