Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

143
Views
React native async function returns empty object

I am trying to get a token stored in securestore, and pass it to url. When I try to call the api the value of the token is just an empty object. I am able to see the value t here if I alert in readToken function. Its not passed to getMovies function.

  const readToken = async () => {
    try {
      const storedToken = await SecureStore.getItemAsync('token');
      return storedToken;
    } catch (e) {
      console.log(e);
    }
  };

  const getMovies = async () => {
    try {
       let url = 'https://someurl.de/api/getschichten/?userid=9&token='+readToken();
       alert(url);
      const response = await fetch(url);
      const json = await response.json();
      setData(json);
    } catch (error) {
      console.error(error);
    } finally {
      setLoading(false);
    }
  }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

So, I changed my code according to kipnodels. Here's my code that works

  let myToken = await readToken();
  let url = 'https://esm.nvii-dev.de/api/getschichten/?userid=9&token='+myToken;
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!