Closed returnundefined closed 5 years ago
@janhommes So to make sure this is not something to do with my application code, I created a basic node JS file that has just these lines of code:
const odata = require('odata');
const oHandler = odata.o('https://services.odata.org/V4/(S(ms4wufavzmwsg3fjo3eqdgak))/TripPinServiceRW/', {
headers: {
'If-Match': '*'
}
});
oHandler.get('People').query().then((data) => {
console.log(data);
});
When I use the TripPin service as in the example code, the response is a nicely formatted json of People entities
When I change that to a Northwind V2
or V4
OData, and access the Categories resource, I get this error
(node:23742) UnhandledPromiseRejectionWarning: #<Response>
(node:23742) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
(node:23742) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Does this library only work with a specific service implementation?
So, for your first post:
I am able to reproduce. There is an issue in the o()
function which let it fail if you don't pass a config. You can work around this by passing an empty object:
const oHandler = odata.o('https://services.odata.org/V3/Northwind/Northwind.svc/', {});
The second is just a configuration issue. The northwind v4 can not handle the If-Match header and needs to add a query parameter to return json:
const odata = require('odata');
const oHandler = odata.o('https://services.odata.org/V3/Northwind/Northwind.svc/', {});
oHandler.get('Categories').query({'$format': 'json'}).then((data) => {
console.log(data);
}).catch((ex) => {
console.log(ex);
});
Will fix the first issue as soon as possible.
the "disablePolyfills of undefined" issue is resolved in 1.0.3
Hi @janhommes Refer #85 . Issue occurs. Please check the usage: (This is in TypeScript Express route)
Resulting error:
Now the error is:
ReferenceError: Headers is not defined
This seems to be coming from o.ts itself.