import { ResponseError } from "./ResponseError.js";
export const fetchJwt = (input, init) => fetch(input, init).then((response) => response
    .json()
    .catch((e) => ({
    message: `${e.name} - ${e.message}`,
}))
    .then(({ message, token: jwt }) => {
    if (!response.ok || (message && !jwt)) {
        throw new ResponseError(message, {
            status: response.status,
            statusText: response.statusText,
            url: response.url,
        });
    }
    return jwt;
}));
//# sourceMappingURL=fetchJwt.js.map