is it possible to use axios in google chrome extension
See original GitHub issueDescribe the issue
is it possible to user axios in google chrome extension? when I am using axios in google chrome extension, shows error:
TypeError: adapter is not a function at dispatchRequest (background.js:836:10) at Axios.request (background.js:599:15) at Axios.post (background.js:634:17) at Function.wrap [as post] (background.js:1276:15) at do_post (background.js:2418:50) at handleTransImpl (background.js:2370:72) at handleMessage (background.js:2551:94) at background.js:2546:5 this is the detail info:
Example Code
export function do_post(url:string,data:any){
axios.post(url, JSON.stringify(data))
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
}
Expected behavior, if applicable
the background could successfully send a http request
Environment
- Axios Version [e.g. 0.25.0]
- Adapter [e.g. FETCH]
- Browser [e.g. Chrome]
- Browser Version [e.g. 90]
- Node.js Version [e.g. 16]
- OS: [e.g. OSX 10.13.4]
- Additional Library Versions [Vue 3]
Additional context/Screenshots
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:8 (1 by maintainers)
Top Results From Across the Web
How do I add the axios package to my chrome extension I'm ...
External modules like axios would need to be bundled into your chrome extension in order for it to work as you intend. You...
Read more >axios-chrome-messaging-adapter - npm
Axios adapter using Chrome Extensions Messaging to perform requests from the background page.. Latest version: 0.6.0, last published: 8 ...
Read more >How to build a Chrome extension that makes API calls.
How to build a Chrome extension that makes API calls. · 1.Create a new directory and navigate into that directory. · 2.We need...
Read more >Axios - Apps on Google Play
News worthy of your time: Axios' expert journalists cut through the noise by reporting only facts that matter. Our concise reporting helps you...
Read more >You.com raises $25 million to take on Google's search ... - Axios
Its results, however, are organized differently and can be personalized by adding apps in areas like news (Axios is in there) or code...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

as mentioned here https://stackoverflow.com/a/70206333/9740955 I used https://www.npmjs.com/package/@vespaiach/axios-fetch-adapter to override adapter, which works
@mehimanshupatil Thank you, so the version seemed to be the problem. I was using version
1.1.3. However, version0.27.2is kinda old, I’ll instead use good oldfetchandfetch-intercept.EDIT
I just found out that
axios==0.27.2isn’t that old, axios just did a huge jump from0.27.2to1.0.0directly (https://www.npmjs.com/package/axios?activeTab=versions), so I think using it is still ok. What do you think @mehimanshupatil ?