import { chain, Either, tryCatch } from '@typed/either' import { HttpResponse } from './types' export function toJson(response: Either>): Either { return chain( ({ responseText }) => tryCatch(() => JSON.parse(responseText)), response, ) }