'Node.js pass Basic Authorization to odata service
I have a backend using Node.js with Express and it is reaching out to an Odata service to retrieve some data.
To do so it is using "odata": "^1.3.1" : https://www.npmjs.com/package/odata/v/1.3.1
However, the service requires I pass Basic Authentication in the request.
I do not see anywhere in their documentation on how to do so. Below is my call to the service within a route, how can I add Basic Authentication to the request?
const express = require("express");
const router = express.Router();
const o = require('odata').o;
process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0;
router.get('/otasks', function(req, res) {
o(process.env.ODATA_SERVER)
.get()
.query()
.then(data => res.json({ payload: data }))
.catch(error => {
console.log(error);
return res.json({ payload: "error" });
});
});
module.exports = router;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
