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

155
Views
is there a way to add a new property to an existing endpoint link?

suppose I am getting information from a given endpoint and rendering the information to the page. the endpoint contains the person's name, address, age, and sport played. Now after I render all the information on the page using javascript and React, I want to ideally add a custom property called votes that will dynamically change and reflect on the site when a user voted for a player. This is how I added the new property.

const fetchPeople = async () => {
    try {
      const response = await fetch(url);
      const data = await response.json();
      const peopleWithVotes = data.map((person, index) => {
        return {
          ...person,
          votes: '0',
        };
      });

      setPeople(peopleWithVotes);
      console.log(people)
    } catch (error) {
      console.error(error);
    }
  };

this is how I have been trying to actually dynamically change the votes but don't know if I'm going in the right direction.

const handleClick = async (event) => {
        const votes = Number(event.target.dataset.votes);
        const requestOptions = {
            method: 'PATCH',
            headers: { 'Content-Type': 'application/json' },
            body: JSON.stringify({ votes: votes + 1 })
        };
        fetch(url, requestOptions)
            .then(response => response.json())
            .then((json) => console.log(json));
    

    }
about 4 years ago · Juan Pablo Isaza
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!