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

167
Views
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 answers
Answer question

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 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!