Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

request should return a promise but instead returns void #152

Closed
sksallaj82 opened this issue Jan 24, 2023 · 1 comment
Closed

request should return a promise but instead returns void #152

sksallaj82 opened this issue Jan 24, 2023 · 1 comment
Labels

Comments

@sksallaj82
Copy link

I did an npm install yesterday, and there seems to be an error here:

Following the JS docs

 const req = new ORequest('http://full.url/health', ( method : 'HEAD' });
 var a = await o('http://another.url').request(req).fetch()

I fetch() doesn't work because request() returns void. I prefer if it returns a promise so I can use .then().catch()

In fact, it'd probably be better if I could just do

const h = o(myConfig)  // where OdataConfig is passed, having everything defined
h.request('/check').query({ ... })

the reason for having the request be this generic is because the passed in myConfig would already have the method (ie get, post, etc) defined.

Better yet, It'd be ideal if OdataConfig has a property called 'queryPath' so that when passed in, I could just do

h.query({ ... })   // throws an error if I do this and querypath is not defined, and request isn't even needed
@janhommes janhommes added the bug label Jan 25, 2023
@janhommes
Copy link
Owner

true, we should add return this; to https://github.com/janhommes/o.js/blob/master/src/OHandler.ts#L202

I am open to a PR here. Otherwise, I will fix it in the next iteration (basically when I have time to look into this again).

This was referenced Sep 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants