Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

114
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda