import { get, post } from './util' import * as types from './types' export const api = (dispatch, method, tag, url, params) => { dispatch({ type: types.api.loading, tag }) get(url, params).then(data => { dispatch({ type: types.api.loaded, tag, data }) }).catch(err => { dispatch({ type: types.api.error, tag, err }) }) } export const getInstitutions = () => dispatch => { api(dispatch, get, 'institutions', '/api/institutions', {}) } export const getPapers = () => dispatch => { api(dispatch, get, 'papers', '/api/papers', {}) } export const postAddress = data => dispatch => { api(dispatch, post, 'address', '/api/address', data) }