-
Notifications
You must be signed in to change notification settings - Fork 81
Open
Description
This http client looks really nice and approachable. :-)
I love the idea of partially configuring the client ahead of time, and having the ability to e.g. only add the path of the URL at the actual callsite. There's one thing I'd wish it would do differently - I am unable to set the method at the call-site:
const myHttpClient = bent('https://example.com', 'json', 200);
const myGetRequest = await myHttpClient('GET', '/api/entity/42');
const myPostRequest = await myHttpClient('POST', '/api/entity', { "name": "My new Entity" });
I can achieve something like the above, by hacking around it, but it feels less clean :-)
const clientOptions = ['https://example.com', 'json', 200];
const myHttpClient = {
get: bent(...clientOptions, 'GET'),
post: bent(...clientOptions, 'POST')
};
const myGetRequest = await myHttpClient.get('/api/entity/42');
const myPostRequest = await myHttpClient.post('/api/entity', { "name": "My new Entity" });
This is just a suggestion - please feel free to close the issue immediately if it isn't something you want to do. I'd love know your reasoning, if there's a good reason why you don't want to - but it's also alright if it's just a matter of taste :-)
hst-m
Metadata
Metadata
Assignees
Labels
No labels