最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Unable to hist NodeJs api with this error "Unhandled promise rejections are deprecated."

网站源码admin35浏览0评论

Unable to hist NodeJs api with this error "Unhandled promise rejections are deprecated."

Unable to hist NodeJs api with this error "Unhandled promise rejections are deprecated."

我想托管一个在渲染网站上解析简历的 nodejs api,这就是代码

//promised-based HTTP client allow to call eden AI API
const axios = require('axios').default;

//initialise file system to access file on computer
const fs = require("fs");

//create mutipart form data parameters form
const FormData = require("form-data");
const form = new FormData();

//add form data parameters to the request
form.append("providers","affinda,hireability")
form.append("file", fs.createReadStream("./Resume-Titouhi-Omar.pdf"));

//configure the request
const options = {
    method: 'POST',
    url: '/v2/ocr/resume_parser',
    headers:{
        authorization: 'Api key',
        'Content-Type': `multipart/form-data; boundary=${form.getBoundary()}`
    },
    data: form
};

//launch the request and print the result
axios.request(options).then((response) =>{
    console.log(response.data);
    const data = JSON.stringify(response.data);
    console.log(data);
});

当我在网站上托管代码时,他显示了这个错误

May 10 09:43:49 PM ==> 使用“node ResumeParsing.js”启动服务 5 月 10 日 09:43:51 PM(节点:52)UnhandledPromiseRejectionWarning:AxiosError:请求失败,状态码为 403 5 月 10 日下午 09:43:51 结算(/opt/render/project/src/node_modules/axios/dist/node/axios.cjs:1909:12) 5 月 10 日下午 09:43:51 在 IncomingMessage.handleStreamEnd (/opt/render/project/src/node_modules/axios/dist/node/axios.cjs:2989:11) 5 月 10 日下午 09:43:51 在 IncomingMessage.emit (events.js:388:22) 5 月 10 日 09:43:51 PM 在 endReadableNT (internal/streams/readable.js:1336:12) 5 月 10 日 09:43:51 PM 在 processTicksAndRejections (internal/process/task_queues.js:82:21) 5 月 10 日 09:43:51 PM(使用

node --trace-warnings ...
显示创建警告的位置) 5 月 10 日 09:43:51 PM(节点:52)UnhandledPromiseRejectionWarning:未处理的承诺拒绝。这个错误要么是在没有 catch 块的情况下在异步函数内部抛出,要么是因为拒绝了一个没有用 .catch() 处理的承诺。要在未处理的承诺拒绝时终止节点进程,请使用 CLI 标志
--unhandled-rejections=strict
(参见.html#cli_unhandled_rejections_mode)。 (拒绝编号:2) 5 月 10 日 09:43:51 PM(节点:52)[DEP0018] DeprecationWarning:未处理的承诺拒绝已弃用。将来,未处理的承诺拒绝将以非零退出代码终止 Node.js 进程。

代码必须返回 json 格式的简历数据

回答如下:
发布评论

评论列表(0)

  1. 暂无评论