Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

141
Vistas
Code working on my machine but not in hosting

I have used the "instagram-private-api" npm package to change the bio of my intagram profile over time. the code is working on my local machine but not on my ubuntu hosting(azure).

Here is the code:

const { IgApiClient } = require("instagram-private-api")
const ig = new IgApiClient()

const USERNAME = "username"
const PASSWORD = "pass"

ig.state.generateDevice(USERNAME)

const main = async () => {
  await ig.simulate.preLoginFlow()
  await ig.account.login(USERNAME, PASSWORD)

  // log out of Instagram when done
  process.nextTick(async () => await ig.simulate.postLoginFlow())

  // change the bio
  await ig.account.setBiography("testing stuff...")
}

main()

Here is the error that comes:

(node:1470) UnhandledPromiseRejectionWarning: IgResponseError: POST /api/v1/accounts/msisdn_header_bootstrap/ - 302 Found; 
    at Request.handleResponseError (/home/mamba/node_modules/instagram-private-api/dist/core/request.js:126:16)
    at Request.send (/home/mamba/node_modules/instagram-private-api/dist/core/request.js:54:28)
(node:1470) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:1470) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Please Help me with this problem, TIA!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Here all the async function written in the given program may or may not return a value . Thus in an event of not receiving any response from the async function a .catch(...) block is expected . The lack of the .catch(..) is the reason you are getting the unhandled promise rejection error .

You can use the following :

.catch((error)=>{
//enter you logic here
console.log("unhandled promice rejection occured");
});

You have to add this at the end of the async functions .

Thus in an event of event of failure the .catch(...) will catch the error and you can also add additional logic when such events occur .

You can refer the following article :

Promises in Node.js (stackabuse.com)

Node.js Process unhandledPromiseRejection Event - GeeksforGeeks

javascript - What is an unhandled promise rejection? - Stack Overflow

What is an unhandled promise rejection? | TOMDUFFYTECH.COM

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda