Skip to content

MrThanlon/restful-proxy

Repository files navigation

restful-proxy

Node.js CI

Probably the most elegant RESTful HTTP client.

中文

One second to get started!

// GET /user/profile/avatar
let res = await restful.user.profile.avatar.get();

// POST /user/profile with data
res = await restful.user.profile.post({
  body: JSON.stringify({ name: 'mrthanlon' })
});

// DELETE /post/me/lastyear
res = await restful.post.me.lastyear.delete();

By default we use fetch() to send the request, you can also use it with axios if you don't like fetch(), or you can also use your own callback function at:

restful.requestCallback = (input, init) => {
  console.log(input, init);
}

You can set baseURL like this:

restful.options = {
  baseURL: 'http://example.com'
};

Installing

Browser

Using jsDelivr CDN:

<script src="https://cdn.jsdelivr.net/npm/restful-proxy/dist/restful.min.js"></script>

Node.js & Webpack & Vite & rollup...

Using npm:

npm install restful-proxy

Notice

In the interactive environment (REPL), since it may run automatically when typing, which may cause URL errors, it is not recommended to use it in an interactive environment.

License

MIT

About

Probably the most elegant RESTful HTTP client.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages