Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

171
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda