'Can axois implement curl -cacert <file> <url>?

I want to get the content of curl -cacert \<file\> \<url\> in my JavaScript API with axois but I am confused where to add the specified certificate file. Or can other libs than axois are able to implement this?

I try to do:

const agent = new https.Agent({ca: fs.readFileSync(<cacert file>),});

var instance = axios.create({ agent: agent });

const response = await instance.get(url);

It seems not working. Any suggestions for this? Thank you so much!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source