UNPKG

@neynar/nodejs-sdk

Version:

SDK to interact with Neynar APIs (https://docs.neynar.com/reference/quickstart)

19 lines (18 loc) 722 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isApiErrorResponse = void 0; const axios_1 = require("axios"); /** * Utility for parsing errors returned by the Neynar API servers. Returns true * if the given error is caused by an error response from the server, and * narrows the type of `error` accordingly. */ const isApiErrorResponse = ( // eslint-disable-next-line @typescript-eslint/no-explicit-any error) => { var _a; if (!(error instanceof axios_1.AxiosError)) return false; return ((_a = error.response) === null || _a === void 0 ? void 0 : _a.data) !== undefined && "message" in error.response.data; }; exports.isApiErrorResponse = isApiErrorResponse;