Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

113
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda