Description
CDS 10 replaces its internal HTTP client with the native fetch API, removing axios as a transitive dependency of @sap/cds. Projects that imported axios directly and declared it in their own package.json are unaffected. Projects that relied on axios being available through CAP's dependency tree without declaring it explicitly will fail to resolve the package after the upgrade. Code that uses axios-specific APIs — interceptors, axios.defaults, or the AxiosError class — must either add axios as an explicit dependency or be rewritten to use the native fetch API or another HTTP client.
How to Check
- [ ] Search source files for
require('axios')andimport ... from 'axios'. - [ ] Search for
axios.interceptors,axios.defaults, andAxiosErrorusage. - [ ] Check
package.jsondependenciesanddevDependencies— ifaxiosis absent there but present in source imports, the project relies on a transitive dep and will break. - [ ] Run
npm ls axiosto confirm whether axios is pulled in transitively from@sap/cdstoday.
Migration Steps
If the project only needs basic HTTP calls, replace axios with native
fetch:diff- const axios = require('axios'); - const response = await axios.get('https://example.com/api/data'); - const data = response.data; + const response = await fetch('https://example.com/api/data'); + const data = await response.json();If the project uses axios-specific features (interceptors, defaults), add axios as an explicit dependency:
diff// package.json { "dependencies": { + "axios": "^1.0.0" } }If interceptors are used for cross-cutting concerns (auth, logging), consider migrating to a
fetchwrapper or middleware pattern instead:diff- axios.interceptors.request.use(config => { - config.headers.Authorization = `Bearer ${token}`; - return config; - }); + async function fetchWithAuth(url, options = {}) { + return fetch(url, { + ...options, + headers: { ...options.headers, Authorization: `Bearer ${token}` }, + }); + }
Notes
The fetch API is available natively in Node.js 18+. Projects still on Node.js 16 must add a polyfill (e.g. node-fetch) or declare an explicit axios dependency. Transitive dependency reliance is common in older projects — run npm ls axios before upgrading to identify whether the project is affected.