blob: a178009b561ce12086f7a19544fb3127dde90842 [file] [log] [blame]
export default class FetchBody {
constructor(private body: RequestInit['body'] | undefined) {}
async getJSONRequestBody() {
if (!this.body) return undefined;
// Using Response is a hack, but it works and converts a possibly long code
// into a one-liner :D
// Source of inspiration: https://stackoverflow.com/a/72718732
return await new Response(this.body).json();
}
}