axios: adapter is not a function (EDIT: after 1st request)
Edit:
I originally thought this was only happening in the DELETE request. It turns out that any request after the first request fails . So if I send the POST and then the POST again, the 2nd time it fails.
TypeError: adapter is not a function
at dispatchRequest (dispatchRequest.js:52)
at async http:/localhost:3004/launchpad/static/js/205.chunk.js:537
–
Hi there
In the same page we have several calls to axios.get
, axios.post
and those work fine.
But using axios.delete
I’m getting a weird error
adapter is not a function
I inspected into axios’ code and found that effectively, defaults.adapter
is undefined
Weird thing is that in other verbs (get, post), adapter is a function (I think is xhrAdapter or something like that)
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 6
- Comments: 24 (1 by maintainers)
Links to this issue
Commits related to this issue
- dartservices - working on axios error: https://github.com/axios/axios/issues/2968 — committed to gridaco/base by softmarshmallow 4 years ago
- working on axios error: https://github.com/axios/axios/issues/2968 — committed to softmarshmallow/uguu-api by softmarshmallow 4 years ago
- fix - axios problem on ssr, check https://github.com/axios/axios/issues/2968 before update — committed to tcaselli/zoop-modulefed-poc by deleted user 3 years ago
- Replace `axios` with raw `fetch` API to talk to smuggler from web (#69) Replace [`axios`](ttps://github.com/axios/axios) with raw [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/fetch) API... — committed to mazed-dev/truthsayer by akindyakov 3 years ago
- dartservices - working on axios error: https://github.com/axios/axios/issues/2968 — committed to dominicwbaker/base by dominicwbaker 4 years ago
XMLHttpRequest is not defined
I’ve had the same problem. But my problem was, that I tried to use Axios inside of a service worker. Unfortunately that doesn’t work since axios can’t work inside of a worker, because of: https://github.com/axios/axios/issues/1219 So the above solution didn’t work (obviously)
I have encountered the same issue when I use axios in chrome extension background.js.
@PedroFolego @tktcorporation @MakarovAV Has anyone been able to solve this when they aren’t using axios directly but axios is being used by another library? Sendgrid is getting this error but I don’t have access to axios through that
I have encountered the same issue when I use axios in a chrome extension background.js. And I resolved this problem.
My extension is made by forking https://github.com/antfu/vitesse-webext/tree/369fc0386970c77e35d401a2deb4d2ef71768aea .
ref: https://zenn.dev/nicopin/articles/5dc87c27bd08de
Maybe your interceptors did something special to the default config. Please check for that.
@qiankunxienb @evanb2 what workaround did you applied to resolve
Also landed here after getting this error trying to use
axios
in a Chrome extension background file. Sad face.Had similar issue, in my case I was using some polyfill plugin with webpack, which made the production code somehow browser like, so
Then I ran the code in Node, and
axios
can’t pick any adaptor by this code:not sure why we need to check
Object.prototype.toString.call(process) === '[object process]
, isn’ttypeof process !== 'undefined'
enough to determine it is a Node environment?To solve this, turns out I don’t actually need the polyfill plugin to build the production code… so I just removed that plugin from webpack, and it worked…
I kind of worked around this with this hack: