Closed chimon2000 closed 7 years ago
Awesome work, this library is just what I have been looking for!
Thanks !
It would be nice to be able to set a baseUrl in the defaults, similar to how you can in axios:
This is just the feedback I need, I will implement it this morning 😄
Just implemented the functionality but in a slightly different way as I prefer immutability over global options ;).
(updated the docs)
// Subsequent requests made using the 'blogs' object will be prefixed with "http://mywebsite.org/api/blogs"
const blogs = wretch().baseUrl("http://mywebsite.org/api/blogs")
// Perfect for CRUD apis
const id = await blogs("").json({ name: "my blog" }).post().json(_ => _.id)
const blog = await blogs(`/${id}`).get().json()
console.log(blog.name)
await blogs(`/${id}`).delete().res()
// ... //
Hope it suits your needs !
That is awesome, thanks for the quick turnaround
It would be nice to be able to set a baseUrl in the defaults, similar to how you can in axios:
Awesome work, this library is just what I have been looking for!