Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/timneutkens/rest-path-suffix

Rest.js interceptor to add a suffix to the request path
https://github.com/timneutkens/rest-path-suffix

Last synced: 21 days ago
JSON representation

Rest.js interceptor to add a suffix to the request path

Awesome Lists containing this project

README

        

# Rest.js path suffix
Rest.js interceptor to add a suffix to the request path

## Installation
Install Rest.js first if you haven't already.
```
npm install --save rest
```

Install path suffix interceptor
```
npm install --save rest-pathsuffix
```

Please note that this module is written in es2015 (es6). So you will need a transpiler like [Babel](http://babeljs.io) to use it.

## How to use
```
const rest = require('rest'),
pathSuffix = require('pathsuffix');

// Wrap pathSuffix interceptor
// Add .json to end of url
const client = rest.wrap(pathSuffix, { suffix: '.json' });

// Calls /products.json
client('/products').then(response => {
console.log(response);
});
```