You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
await$fetch('/admin-api/test/index',{retryStatusCodes: [401],onRequest({request, options}){// todo add accessToken to header},onResponse({request, options, response}){/* my response like { ok: true, status: 200, _data: { code: 401, msg: 'token is invalid', data: null } } */if(response._data.code===401){// throw new Error// I want to manually throw an error so that ofetch catches it in the onResponseError interceptor,// where I can refresh the token. Then, ofetch should retry the request.}},onResponseError({request, options, response, error}){// If I threw the error manually, then refresh the token// in the end, retry the request automatically}})
ps: I know returning http status code in response._data like a shit, but I have no other way
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
ps: I know returning http status code in response._data like a shit, but I have no other way
Beta Was this translation helpful? Give feedback.
All reactions