https://github.com/eperedo/hapi-axios
a fun and lightweight integration between hapi and axios
https://github.com/eperedo/hapi-axios
axios hapi semantic-release tape
Last synced: about 2 months ago
JSON representation
a fun and lightweight integration between hapi and axios
- Host: GitHub
- URL: https://github.com/eperedo/hapi-axios
- Owner: eperedo
- Created: 2018-08-09T23:12:54.000Z (almost 7 years ago)
- Default Branch: dev
- Last Pushed: 2018-08-09T23:24:53.000Z (almost 7 years ago)
- Last Synced: 2025-03-13T04:11:19.523Z (2 months ago)
- Topics: axios, hapi, semantic-release, tape
- Language: JavaScript
- Size: 46.9 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# hapi-axios
> a fun and lightweight integration between hapi and axios
### Dependencies
Hapi >= 17.5.3
Axios >= 0.18.0### Usage
1. Installation
```bash
npm i hapi-axios
```2. Register
```js
const Hapi = require('hapi');
const HapiAxios = require('hapi-axios');const server = new Hapi.Server({
host: 'localhost',
port: 4000,
});await server.register({
plugin: HapiAxios,
options: {
instances: [
{
name: 'typicode',
axios: {
baseURL: 'https://jsonplaceholder.typicode.com',
// you can use any axios config here. https://github.com/axios/axios#creating-an-instance
},
},
],
},
});await server.start();
```3. Usage
```js
server.route({
handler: async (request, h) => {
const { typicode } = request.server.plugins['hapi-axios'];
const { data } = await typicode.get('users');
// GET https://jsonplaceholder.typicode.com/users
return h.response(data);
},
method: 'GET',
path: '/users',
});
```