Node.JS Request - Invalid URI “/”

微笑、不失礼 提交于 2019-12-06 20:26:05

问题


I'm using request in my app to send a POST request over HTTPS with Client Authentication. Request always throws an error Error: Invalid URI "/" and I couldn't do anything to solve it. I've tried used url.parse instead of passing a string but it's still the same.

request.post({
        uri: 'https://localhost:5000',
        key: credentials.key,
        ca: credentials.ca,
        cert: credentials.cert,
        passphrase: credentials.passphrase,
        rejectUnauthorized: false
    }, { form: { data: payload }});

回答1:


Turns out it was caused by passing the second object to request.post, it should be inside the first object.

request.post('https://localhost:5000/', {
    key: credentials.key,
    ca: credentials.ca,
    cert: credentials.cert,
    passphrase: credentials.passphrase,
    rejectUnauthorized: false,
    form: { data: payload }
});


来源:https://stackoverflow.com/questions/31186241/node-js-request-invalid-uri

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!