0

I want to fetch the token from async-storage but it returns a Promise of type string or undefined. Since fetchOptions is a function that returns a object of type RequestInit here is what i've tried

export const client = createClient({
  url,
  fetchOptions: async () => {
    const token = (await retrieve(TOKEN_KEY)) ?? "";
    return {
      credentials: "include",
      headers: { authorization: token ? `Bearer ${token}` : "" },
    };
  },
});

But typescript is not happy with me. How can I wake around this??

crispengari
  • 7,901
  • 7
  • 45
  • 53

0 Answers0