TypeError: (e.adapter || s.adapter) is not a function

I’m trying to run a request with axios & I get the following error when await axios.get(.... Has anyone encounter this problem too?

TypeError: (e.adapter || s.adapter) is not a function


Same here with @sengrid/mail. The error is actually different and a lot more complicated when I remove:

node: {fs:'empty'}

from my webpack.config.js. And can be traced back to require('fs') in @sendgrid/mail.

TLDR: use fetch (not cross-fetch)

In axios, both of the adapter checks (xhr and http) fail when running in cloudflare worker.
see axios/defaults.js at d99d5faac29899eba68ce671e6b3cbc9832e9ad8 · axios/axios · GitHub

Eventually, axios will have a fetch adapter hopefully. See Feature request: fetch based adapter · Issue #1219 · axios/axios · GitHub and Change from Axios to Fetch API to support Serverless Workers. · Issue #10 · TileDB-Inc/TileDB-Cloud-JS · GitHub

1 Like

Just for clarity when you say use fetch you mean the native fetch implementation instead of the cross-fetch that axios is usig?