Closed luchanan closed 2 years ago
hi, i has a question:
this code will enter twice when refresh token finished.
if i dont change code Promise.resolve(res) will not entry again.
const service = axios.create({ timeout: 5000, }) service.interceptors.response.use( (response: AxiosResponse<any>) => { // first response: {config: {}, data: {code: '200', data: []}, status: 200, ....} // second response: {code: '0', data: []} let res = response.data if (+res.code === 200) { // here will return {code: '0', data: []} return Promise.resolve(res) }
now my solution is:
service.interceptors.response.use( (response: AxiosResponse<any>) => { let res = response.data if (!response.config) { // temp solution res = response } if (+res.code === 200) { return Promise.resolve(res) }
what can i avoid this? thanks
Please, use StackOverflow or Github's Discussions. Thank you.
same issue
hi, i has a question:
this code will enter twice when refresh token finished.
if i dont change code Promise.resolve(res) will not entry again.
now my solution is:
what can i avoid this? thanks