axios请求报错SSL Error: Unable to verify the first certificate

import axios from "axios";

const https = require("https");

// 创建忽略 SSL 的 axios 实例

const ignoreSSL = axios.create({

  httpsAgent: new https.Agent({

    rejectUnauthorized: false,

  }),

});

// 在 axios 请求时,选择性忽略 SSL

const agent = new https.Agent({

  rejectUnauthorized: false,

});

axios

  .get("http://myjson.dit.upm.es/api/bins/g9l5", { httpsAgent: agent })

  .then((res) => res.data);

你可能感兴趣的:(axios请求报错SSL Error: Unable to verify the first certificate)