export function fetchData(path, init = undefined) {
  return fetch(process.env.VUE_APP_API + path, init);
}

export function postJson(path, data) {
  return fetchData(path, {
    method: 'POST',
    body: JSON.stringify(data),
    headers: {'Content-Type': 'application/json'}
  });
}

export function postAndGetJson(path, data) {
  return postJson(path, data).then(response => response.json());
}

export function getJson(path) {
  return fetchData(path).then(response => response.json());
}