pradel / node-instagram

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

message: 'invalid json response body at when using instagram.get('users/'+user_id) #141

Closed helxsz closed 4 years ago

helxsz commented 5 years ago

i used the following code to get some users 's pictures, i am testing https://0be58cff.ngrok.io/users/adorofarm, but it gives me an error :

{ FetchError: invalid json response body at https://api.instagram.com/v1/users/adorofarm?access_token=2959557543.a40649d.b9fe045ad7f24806b1ae196e1de3dd45 reason: Unexpected token < in JSON at position 0 at /Users/xisizhe/Documents/projects/mean-master/node_modules/_node-fetch@2.2.0@node-fetch/lib/index.js:239:32 at at process._tickCallback (internal/process/next_tick.js:188:7) message: 'invalid json response body at https://api.instagram.com/v1/users/adorofarm?access_token=2959557543.a40649d.b9fe045ad7f24806b1ae196e1de3dd45 reason: Unexpected token < in JSON at position 0', type: 'invalid-json' }

how to solve it?

app.get("/users/:user_id",async (req, res) => {
  let user_id = req.params.user_id;
  console.log('user_id  ',user_id);
  try {
    const profileData = await instagram.get('users/'+user_id);
    const media = await instagram.get('users/'+user_id+'/media/recent');
    console.log(profileData);
    res.send({ user: profileData.data, posts: media.data});
  } catch (err) {
    console.log(err);
  }

});
pradel commented 5 years ago

Hey @helxsz I will take a look and try to reproduce your issue

helxsz commented 5 years ago

thanks, @pradel , I am here to help you test too if you need me

Benjamin-Willard commented 5 years ago

I get this same issue from time to time and when I actually hit the endpoint itself it loads up just fine. I am not sure what exactly is causing this issue to occur.

pradel commented 4 years ago

I am closing the issues in this repo: The legacy Instagram API is deprecated and will be disabled on June 29, 2020. More information instagram.com/developer.