简体   繁体   中英

How do I add the axios package to my chrome extension I'm working on?

I'm trying to make a chrome extension and I wanted to use the axios package. When I try to test my code in chrome I get this error . I've installed the package by executing npm install axios in the console. Sorry if this is a rudimentary question, I don't really know what I am doing. Thanks for the help!

External modules like axios would need to be bundled into your chrome extension in order for it to work as you intend. You can use a bundler like webpack in order to do this, but there is a decent amount of configuration needed to get up and running.

I would recommend using the fetch API as an alternative. It's already freely available in chrome extensions and works in very similar way to axios.

A fuller code example comparing fetch to axios : https://blog.logrocket.com/axios-or-fetch-api/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM