【问题标题】:Unhandled promise rejection error when I using parsing我使用解析时未处理的承诺拒绝错误
【发布时间】:2020-04-24 17:45:39
【问题描述】:

当我运行以下代码时:

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();

})();

但我收到以下错误:

我搜索了整个互联网,但一无所获。 我该如何解决这个问题?

【问题讨论】:

    标签: node.js typescript ts-node


    【解决方案1】:

    改变

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

    const dashdash = require('dashdash');
    

    【讨论】:

      猜你喜欢
      • 2017-05-21
      • 2017-11-24
      • 1970-01-01
      • 2018-11-08
      • 2019-10-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多