A library that creates an axios instance for destinations in SAP cloud foundry.
npm install sap-request-helpersYou can address destinations pointing to Internet and onPremise systems. The library will handle the authentication and proxy configuration.
If you want to connect with the current user (e.g. with principal propagation) just send the JWT token to the destination in the authorization header.
``bash`
$ npm install -s sap-request-helpers
`js
const SapCfAxios = require('sap-request-helpers').default;
const axios = SapCfAxios("
axios({
method: 'POST',
url: '/BookSet',
data: {
title: "Using Axios in SAP Cloud Foundry",
author: "John Doe"
},
headers: {
"content-type": "application/json"
}
});
`
For connecting to a destination as the current user, we send the current JWT token in the authorization header of the request.
`js`
const SapCfAxios = require('sap-request-helpers').default;
const axios = SapCfAxios("
var authorization = req.headers.authorization;
const response = await axios({
method: 'GET',
url: '/iwfnd/catalogservice/',
params: {
"$format": 'json'
},
headers: {
"content-type": "application/json",
authorization
}
});
> NOTE: The JWT Token sent to the backend does not contain the properties name, login_name or mail. If you use principal propagation in the cloud connector you have to use ${email} or ${user_name} in the client certificate template
js
const SapCfAxios = require('sap-request-helpers').default;
const cpi = SapCfAxios("cpi_destination_name");var authorization = req.headers.authorization;
const response = await cpi({
method: 'POST',
url: '/Bookset',
headers: {
"content-type": "application/json"
},
data: {
title: "Using Axios in SAP Cloud Foundry",
author: "John Doe"
}
xsrfHeaderName: "x-csrf-token",
data: {vatNumber},
});
``