@yrnd1/

axios-morphism-simple

ES6

No description

fork
loading

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.15955154171136576","path":"main.js","file":{"path":"main.js","content":{"asEncoding":{"base64":"aW1wb3J0IGF4aW9zIGZyb20gJ2F4aW9zJwppbXBvcnQgeyBhcHBseSB9IGZyb20gJ2F4aW9zLW1vcnBoaXNtJwoKY29uc3QgcGVvcGxlU2NoZW1hID0gewogIG5hbWU6ICduYW1lJywKICBoZWlnaHQ6ICdoZWlnaHQnLAogIHdlaWdodDogJ21hc3MnCn07Cgpjb25zdCBjb25maWd1cmF0aW9uID0gewogIHVybDogJ2h0dHBzOi8vc3dhcGkuY28vYXBpLycsCiAgaW50ZXJjZXB0b3JzOiB7CiAgICByZXNwb25zZXM6IFsKICAgICAgeyBtYXRjaGVyOiAnL3Blb3BsZScsIHNjaGVtYTogcGVvcGxlU2NoZW1hLCBkYXRhU2VsZWN0b3I6ICdyZXN1bHRzJyB9LAogICAgICB7IG1hdGNoZXI6ICcvcGVvcGxlLzppZCcsIHNjaGVtYTogcGVvcGxlU2NoZW1hIH0KICAgICAgXSwKICAgIHJlcXVlc3RzOiBbXQogIH0KfTsKCmNvbnN0IGNsaWVudCA9IGF4aW9zLmNyZWF0ZSh7YmFzZVVSTDogJ2h0dHBzOi8vc3dhcGkuY28vYXBpLyd9KTsKYXBwbHkoY2xpZW50LCBjb25maWd1cmF0aW9uKTsKCmNsaWVudC5nZXQoJy9wZW9wbGUvMScpLnRoZW4ocmVzcG9uc2UgPT4gewogIGNvbnNvbGUubG9nKEpTT04uc3RyaW5naWZ5KHJlc3BvbnNlLmRhdGEsIG51bGwsIDIpKQp9KQ=="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import axios from 'axios'
import { apply } from 'axios-morphism'

const peopleSchema = {
  name: 'name',
  height: 'height',
  weight: 'mass'
};

const configuration = {
  url: 'https://swapi.co/api/',
  interceptors: {
    responses: [
      { matcher: '/people', schema: peopleSchema, dataSelector: 'results' },
      { matcher: '/people/:id', schema: peopleSchema }
      ],
    requests: []
  }
};

const client = axios.create({baseURL: 'https://swapi.co/api/'});
apply(client, configuration);

client.get('/people/1').then(response => {
  console.log(JSON.stringify(response.data, null, 2))
})
Babel Compiler v6.4.4 Copyright (c) 2014-2015 Sebastian McKenzie