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

116
Views
Llamada a la API nativa de React y variable de extracción

Soy nuevo en reaccionar nativo, así que tengan paciencia conmigo aquí. Tengo un componente nativo de reacción llamado Plaid Link, que devuelve un token público. Una vez que obtengo eso, llamo a Plaid para intercambiar public_token por access_token, que necesito guardar como una variable.

Actualmente, tengo esta llamada después de que Plaid Link devuelve public_token. No puedo decir exactamente dónde está el problema, pero no creo que esté extrayendo correctamente el access_token de la respuesta.

 //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); });

Esta es la respuesta que debe devolver la llamada (nuevamente, tratando de guardar access_token)

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

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

0

Intenta hacer esto:

Primero declara un useState antes que todo

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

y luego en tu código

 .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 }) })

Ahora tiene el token de acceso almacenado en {ApiData.access_token}

Espero que esto ayude y lo siento si no es así o si no entendí tu pregunta.

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!