janhommes / o.js

o.js - client side oData lib.

Home Page:https://janhommes.github.io/o.js/example/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

o constructor taking two parameters when there should should be 1 parameter

sksallaj82 opened this issue · comments

so reading the docs, I see you can do either

let check = (myConfigO: OdataConfig) => {
    const h1 = o('http://my.url')
    const h2 = o('http://my.url', myConfig)
}

but myConfig already has a rootUrl you can set. Can't you just do:

 const h2 = o('http://my.url', myConfig)

sorry, I don't get this. What is exactly the issue? Which docs you mean?

Oh wow, that's cryptic; I didn't realize I wrote it so poorly.

So in the project readme (I referred to that as the docs), you can create two handlers:

let check = (myConfigO: OdataConfig) => {
    const h1 = o('http://my.url')
    const h2 = o('http://my.url', myConfig)
}

The readme shows examples of how you can get hander h1, but later in the section 'Options,' you can create an OdataConfig that takes in a RequestInit and a bunch of other properties. In OdataConfig class, there is a property where you can define the root URL, aptly named rootUrl, this is NOT mentioned on the readme but it's there:

rootUrl?: URL | string;

Due to having a rootUrl within the config, wouldn't this effectively eliminate the need to pass it "again" as the first parameter?

So handler h2 becomes

const h2 = o(myConfig)

sorry, missed your comment. It always needs two parameters. I updated the doc for this.