ptth

A simple http client with middleware for the browser

Usage no npm install needed!

<script type="module">
  import ptth from 'https://cdn.skypack.dev/ptth';
</script>

README

ptth

A simple http client with middleware for the browser

Installation

npm install --save ptth

Or grab the script from the build folder.

Code Example

ptth.use(function(res, next) {
    console.log(res.status);
    next();
});

ptth('http://swapi.co/api/starships')
    .header('content-type', 'application/json')
    .params('page', '2')
    .data({ 'form': 'data' })
    .post(function(res) {
        if (res.ok) {
            console.log(res.body);
        }
    });

// logs response status code and body of the response

API Reference

See the docs.

License

MIT