Skip to content

Instantly share code, notes, and snippets.

View teal-front's full-sized avatar
🚀
Learning

Aaron Sprinkle teal-front

🚀
Learning
View GitHub Profile
@teal-front
teal-front / fetch.js
Last active March 28, 2024 02:47
project-snippets
/**
* fetch api
* 1. 确保返回 fulfilled promise,没有rejected promise,所以也不用处理错误
* 带错误的Promise<[null, data]>
* 正常结果的Promise<[{code: number, msg: string}]>
* 2. 使用了signal来处理超时情况
*/
// 如果是sdk项目,使用ponyfill,如果是自己的项目,使用polyfill(isomorphic-fetch)
import fetchPonyfill from "fetch-ponyfill";
import pickBy from "lodash/pickBy";