janhommes / o.js

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

o() is not a function #84

Closed arunagnihotri closed 5 years ago

arunagnihotri commented 5 years ago

Hi, does it compile successfully or work on nodejs 11? I am getting an error at o().config({...}) TypeError: o is not a function

Here is the piece of code I am trying: `'use strict';

let o = require('o.js'); let request = require('request');

// You credential let Credentials = require('./crendentials');

// Your host let sUrl = "http://:/sap/opu/odata/sap/processmanagement/";

// Retrieve the data o().config({ version: 4, username: Credentials.username, password: Credentials.password, endpoint: sUrl });`

janhommes commented 5 years ago

mh, which version are you refering to.

Latest version 1.0.0 should work, but there is no.config anymore. Here is a snipped how it works now:

const odata = require('odata');

const oHandler = odata.o('https://services.odata.org/V4/%28S%28wptr35qf3bz4kb5oatn432ul%29%29/TripPinServiceRW/', {
  headers: {
    'If-Match': '*'
  }
});

oHandler.get('People').query().then((data) => {
  console.log(data);
});
arunagnihotri commented 5 years ago

Thanks. I'll try and let you know.

arunagnihotri commented 5 years ago

works now (on Node 11). Thanks for your prompt response.