Skip to content

Instantly share code, notes, and snippets.

View skyblue's full-sized avatar
🎯
Focusing

Skyblue skyblue

🎯
Focusing
View GitHub Profile
@skyblue
skyblue / handleError.ts
Created October 23, 2020 09:14 — forked from yuya-takeyama/handleError.ts
Handle Response Error of JSON API in TypeScript (using async/await)
import fetch, { Response } from 'node-fetch';
interface ResponseWithParsedJson extends Response {
parsedJson?: any;
}
const toResponseWithParsedJson = (
res: Response,
json: any,
): ResponseWithParsedJson => {