janhommes / o.js

o.js - client side oData lib.
https://janhommes.github.io/o.js/example/
MIT License
238 stars 57 forks source link

Node example incorrect #99

Closed phmasek closed 4 years ago

phmasek commented 4 years ago

Documentation says the following:

const o = require('odata');

// promise example
o('http://my.url')
  .get('resource')
  .then((data) => console.log(data));

however I receive an error copying the code: TypeError: o is not a function

To get it to work I had to do the following:

const o = require('odata').o;

// promise example
o('http://my.url')
  .get('resource')
  .then((data) => console.log(data));
janhommes commented 4 years ago

yes, you are right. We need to update the docs as well with the input in #96

Maybe like this:

const { o } = require('odata');

// promise example
o('http://my.url')
  .get('resource')
  .then((data) => console.log(data));

object destruction should work in the latest node versions, or?