I am new to React Native and coming from a PHP background.
storage.js
const getToken = async () => {
try {
return await SecureStore.getItemAsync(authKey);
} catch (error) {
console.log('Error getting auth token:', error)
}
}
Client.js
const authToken = async () => await storage.getToken();
console.log('clientjs authtoken -->', authToken());
const apiClient = create({
baseURL: 'http://www.example.com/mobile',
headers: { Authorization: 'Bearer ' + authToken() },
});
This console.log shows me this: clientjs --> {"_U": 0, "_V": 0, "_W": null, "_X": null}.
I've also simply tried writing: const authToken = storage.getToken(); but getting the same result. What am I doing wrong? Any help would be appreciated.
authToken, being defined as anasyncfunction, would always return a promise. Is this your actual code?