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

编程入门 行业动态 更新时间:2024-10-04 05:35:10

Unable to hist NodeJs <a href=https://www.elefans.com/category/jswz/34/1771441.html style=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 格式的简历数据

回答如下:

更多推荐

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

本文发布于:2024-05-30 23:16:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1771031.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:api   error   NodeJs   Unable   hist

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!