Untitled
unknown
plain_text
a year ago
812 B
13
Indexable
Never
export const refreshAccessToken = async (refreshToken: string) => { const requestOptions = { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ refresh: refreshToken }), }; try { const response = await fetch( `${BASE_URL}/auth/login/refresh/`, requestOptions, ); const data = await response.json(); console.log('Data: ', data); if (data.access_token) { // Save the new access token console.log('New access: ', data.access_token); await AsyncStorage.setItem('@access_token', data.access_token); return data.access_token; } else { throw new Error('Failed to refresh access token'); } } catch (error) { console.error('Failed to refresh access token:', error); throw error; } };