0.2.0 • Published 2 years ago

restful-proxy v0.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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

0.2.0

2 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago