使用axios請求時,報錯:`unable to verify the first certificate`
找了幾個解決辦法 發現都不行,就使用request進行請求,發現還是“unable to verify the first certificate”,
根據 https://www.reddit.com/r/node/comments/7vyc2q/cant_get_https_request_with_certificate_to_work/ 給出的解決辦法,
在請求頭中加 strictSSL: false
請求的url需要加參數時,又報錯:
Error: options.uri is a required argument
const url ='請求地址'; request({ method: 'GET', uri: url, strictSSL: false }, function (error, response, body) { if (!error && response.statusCode == 200) { let deleList = JSON.parse(body); } })
//有參數時 const leturl = '請求地址'; request({ method: 'GET', uri: leturl, qs: { offset: 0, limit: delegateTotal }, strictSSL: false }, function (err, res, data) { if (!err && res.statusCode == 200) { let proList = JSON.parse(data); } })
//post有參數的請求,qs: {} 改為 form: {}