class ResponseError extends Error {
  response;
  status;
  constructor(response, message) {
    super(message);
    this.name = 'ResponseError';
    this.response = response;
    this.status = response.status;
  }
}
async function postData({
  url,
  method = 'POST',
  ...httpOptions
}, data, fetcher = fetch) {
  const response = await fetcher(url, {
    method,
    body: data,
    ...httpOptions
  });
  if (!response.ok) {
    throw new ResponseError(response, response.statusText);
  }
  return response;
}

export { ResponseError, postData };
//# sourceMappingURL=postData.mjs.map
