import baseFetch from "unfetch"; import { AuthStore } from "./stores"; export const fetch = (url, opts) => { const { isAuthenticated, user } = AuthStore.getRawState(); opts = opts || {}; opts.headers = opts.headers || {}; if (isAuthenticated) { opts.headers.Authorization = "Bearer " + user.accessToken; } return baseFetch(process.env.REACT_APP_API_BASE_URL + url, opts); };