Необработанная ошибка отклонения обещания при использовании парсинга - PullRequest
0 голосов
/ 24 апреля 2020

Когда я запускаю следующий код:

const { dashdash } = require('dashdash');

const options = ....; //it's long so I replace them with ... to let me publish the post.

async function upload_photo() {
    const parser = dashdash.createParser({options: options});
    const opts = parser.parse(process.env);
    const path = opts.imagepath + "\\" + opts.imagenumber + "." + opts.imageformat;
    console.log("***********"+path+"************" + "\\" + opts.imagenumber + "." + opts.imageformat);
      const { latitude, longitude, searchQuery } = {
        latitude: 0.0,
        longitude: 0.0,
        // not required
        searchQuery: 'place',
      };

  const mediaLocation = locations[0];
  console.log(mediaLocation);

  const publishResult = await ig.publish.photo({

    file: await readFileAsync(path),
    // optional, default ''
    caption: 'Delicious food',

  });

  console.log(publishResult); 
}

(async () => {

    await login();
    await upload_photo();
    console.log('Succsess!');
    await logout();

})();

Но я получаю следующую ошибку:

screenshot of the error

Я искал весь inte rnet, но Я ничего не нахожу. Как я могу решить это?

1 Ответ

0 голосов
/ 24 апреля 2020

изменить

const { dashdash } = require('dashdash');

на

const dashdash = require('dashdash');
...