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

171
Visualizações
Identifying key for value in body when key is not explictly passed in

I am looking to identify how the body looks for following request.

This is existing code which sends a post call to another client and also redirects to that client.

When normally making a post call, I am expecting the body to look something like this.

{
    someKey: 'some value'
}

But in this case, only the value is being set. What is the key here?

//Just from a normal js file. 
export const postData = (myRef, token, link) => {

  // question is on this line. Just setting a value. What is the key for the post body?
  myRef.current.children[0].value = token;
  myRef.current.action = link;
  myRef.current.submit();
};

This is the component where on click we call above function where we post and redirect to link.

const AComponent = () => {
  const myRef = React.useRef();
  const submit = () => {
    postData(myRef, 'some long token', 'www.google.com');
  };

  return (
      {/* Button is just another component that acts like a normal html button with some styling*/}
    <Button onClick={submit}>
      Click Me!
    </Button>
  );
};

export default AComponent;
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can do this by creating an Object & then assigning {key: value} pair to it.

const obj = new Object();

obj['some key'] = "some value";

Maybe this is helpful to you, if still, this doesn't answer your question, you can ping me for further reference.

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