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

325
Vistas
How to create an object of arrays in javascript

I have a collection in mongodb with a value o type array with 12 rows in it. See the screenshot: enter image description here

In my code make an axios request in the componentDidMount and successfully get the respone and values

async componentDidMount() {

    const {data: locations} = await axios.get('http://localhost:4000/try1');
    this.setState({locations})
    console.log(locations)

    // Use processCsvData helper to convert csv file into kepler.gl structure {fields, rows}
    const data = Processors.processCsvData(nycTrips);
    console.log(data)

    // Create dataset structure
    const dataset = {
      data,
      info: {
        // `info` property are optional, adding an `id` associate with this dataset makes it easier
        // to replace it later
        id: 'my_data'
      }
    };
    // addDataToMap action to inject dataset into kepler.gl instance
    this.props.dispatch(addDataToMap({datasets: dataset}));
}

The problem is I am getting the location object like shown in this screenshot:

enter image description here

but my required output is as shown below:

enter image description here

I need the required output to pass it to my mapping application so that the map markers can be generated.

Please advise how I can create an object in the required format.

Following is my simple get api:

app.get('/try1', (req, res) => {
    try1.find()
    .then(data => res.json(data))
})

Thanks in advance guys.

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