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

112
Views
React Native API call and extracting variable

I'm new to react native, so bear with me here. I have a react native component calling Plaid Link, which returns a public_token. Once I get that, I call Plaid to exchange the public_token for the access_token, which I need to save as a variable.

Currently, I have this call after Plaid Link returns the public_token. I can't tell exactly where the issue is, but I don't think I'm extracting the access_token from the response properly.

    //Call Plaid Public Token Exchange: PublicToken -> AccessToken
    fetch("https://sandbox.plaid.com/item/public_token/exchange", {
     method: "POST",
     headers: {
    Accept: 'application/json',
        'Content-Type': 'application/json'
     },
     body: JSON.stringify({
       "client_id": "[ClientID]",
       "secret": "[SandboxSecretID]",
       "public_token": success.publicToken
      }),
    })
     .then(response => response.json())
     .then(response => {
      console.log(response.content);
      setVariable({ key: 'AccessToken', value: access_token })
     })
     .catch(err => {
       console.log(err);
     });

This is the response the call should return (again, trying to save access_token)

{ "access_token": "access-sandbox-xxxxx", "item_id": "YYYYYYYY", "request_id": "ZZZZZZZZZ" }

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try to do this:

First declare a useState before everything

const [ApiData, setApiData] = useState(
    { access_token : null, item_id : null, request_id : null }
)

and then after in your code

  .then(response => response.json())
  .then(response => {
       console.log(response.content);
       setApiData({
            access_token : response.content.access_token
            item_id : response.content.item_id
            request_id : reponse.content.request_id
       })
  })

Now you have the access_token stocked in {ApiData.access_token}

Hope this helps and sorry if it doesn't or if I didn't understand your question.

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!