Registry / cloud / sap-cf-axios

sap-cf-axios

JSON →
library1.0.2jsnpmunverified

Wrap axios to use the SAP Cloud Foundry destination Service. Version 1.0.2, maintained by Flexso (unofficial). Provides an axios instance configured for SAP BTP destinations, handling authentication (basic, OAuth2ClientCredentials, OAuth2SAMLBearerAssertion, OAuth2UserTokenExchange, principal propagation), proxy for on-premise, and automatic X-CSRF-Token fetching. Ships TypeScript types. Alternatives: @sap/xssec, @sap/cf-tokens, sap-cloud-sdk (official but heavier).

npm install sap-cf-axios
INSTALL
IMPORT
SIG · SAP-CF-AXIOS
S
sap-cf-axios
cloudjavascriptv1.0.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SapCfAxios
import SapCfAxios from 'sap-cf-axios'
const SapCfAxios = require('sap-cf-axios')
Package has a default export. In CommonJS, use require('sap-cf-axios').default. In ESM, import SapCfAxios from 'sap-cf-axios' works directly.
default
const SapCfAxios = require('sap-cf-axios').default
const SapCfAxios = require('sap-cf-axios')
The default export is assigned to module.exports.default, not module.exports.
SapCfAxios
import SapCfAxios from 'sap-cf-axios'
const { SapCfAxios } = require('sap-cf-axios')
There is no named export SapCfAxios; it is a default export.

Creates an axios instance for a named BTP destination and makes a GET request. Runs in Node.js with SAP Cloud Foundry environment.

import SapCfAxios from 'sap-cf-axios'; import axios from 'axios'; async function callDestination() { const axiosInstance = SapCfAxios('MY_DESTINATION'); try { const response = await axiosInstance({ method: 'GET', url: '/api/data', headers: { 'content-type': 'application/json' } }); console.log(response.data); } catch (error) { console.error('Error:', error); } } callDestination();
Debug
Known issues
gotchaDefault export requires .default in CommonJS.
fix
Use require('sap-cf-axios').default instead of require('sap-cf-axios')
affects: >=1.0
gotchaAuthorization header must be passed explicitly for user-dependent flows.
fix
Include the JWT token as authorization header in the request config.
affects: >=1.0
deprecatedCalling SapCfAxios() with two arguments (destination, axiosConfig) is correct; third argument for XSRF config is optional.
fix
Use SapCfAxios(destinationName, axiosConfig?, xsrfConfig?) - see README for correct usage.
affects: >=1.0
breakingX-CSRF-Token handling uses xsrfHeaderName in request config.
fix
Set xsrfHeaderName in the request config (not as a separate parameter) to enable automatic token fetch.
affects: >=1.0
Errors
Common errors & fixes
TypeError: SapCfAxios is not a constructor
ESM import syntax used with CommonJS module or vice versa.
fix
Use import SapCfAxios from 'sap-cf-axios' for ESM, or const SapCfAxios = require('sap-cf-axios').default for CommonJS.
Error: Cannot find module 'sap-cf-axios'
Package not installed or missing dependencies.
fix
Run 'npm install sap-cf-axios' and ensure axios is also installed.
Error: Could not fetch destination 'X'
Destination name does not exist in SAP BTP subaccount or missing environment variables.
fix
Verify destination name and that the app is bound to the destination service.
AxiosError: Request failed with status code 403
Invalid or missing JWT token for user-dependent authentication.
fix
Ensure authorization header contains a valid JWT token.
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies
axiosrequiredHTTP client used for requests
Agent activity
16 hits · last 30 days
node
14
Amazon
1
Resources
sap-cf-axios — npm install sap-cf-axios · libregistry