let aborter = new AbortController()
const fetchReq = (
path: string,
method: string
): Promise<any> => {
aborter = new AbortController()
return fetch(${url}${path}
, {
method,
headers: {
...
},
signal: aborter.signal,
})
}
}
const getReq = (path: string, params?: object): Promise<any> => {
return fetchReq(path, 'GET', params).then(res => {
return res.json()
})
}