restful-proxy

0.2.0 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i restful-proxy

Weekly Downloads

1

Version

0.2.0

License

MIT

Unpacked Size

8.59 kB

Total Files

11

Last publish

Collaborators

  • mrthanlon