about summary refs log tree commit diff
path: root/app/assets/javascripts/components/api.jsx
blob: 080c2bd6a691210c2f70f3acc3b1f2472612b52c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import axios from 'axios';
import LinkHeader from 'http-link-header';

export const getLinks = response => {
  const value = response.headers.link;

  if (!value) {
    return { refs: [] };
  }

  return LinkHeader.parse(value);
};

export default getState => axios.create({
  headers: {
    'Authorization': `Bearer ${getState().getIn(['meta', 'access_token'], '')}`
  },

  transformResponse: [function (data) {
    return JSON.parse(data);
  }]
});