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

145
Vistas
Node MySQL Geosearch

I am trying to search a MySQL database based on the north, south, east, and west bounds of a map. I am using Nodejs with express. When I use postman or enter the url in with the LAT and LON for the search it will work just fine. The issue comes when I try to build the URL sting form the front-end. I get back and empty JSON object.

app.get('/search', (req, res) => {
  try {
    connection.query(`SELECT * FROM photos WHERE lat BETWEEN '${req.query.north}' and '${req.query.south}' and lng BETWEEN '${req.query.west}' and '${req.query.east}'`, function (error, results, fields) {
      if (error) throw error;
      //console.log(results);
      res.send(results);
    });
  }
  catch (exception_var) {
    console.log("Error");
  }
})

This is the front-end client

async function mysearch() {
    myFeatureGroup.clearLayers();
    const mapEast = map.getBounds().getEast().toString();
    const mapWest = map.getBounds().getWest().toString();
    const mapNorth = map.getBounds().getNorth().toString();
    const mapSouth = map.getBounds().getSouth().toString();
   
    // http://127.0.0.1:3000/search?north=42.06254817666338&south=43.002638523957906&east=-89.55780029296875&west=-91.41448974609375
    // http://127.0.0.1:3000/search?north=${mapNorth}&south=${mapSouth}&east=${mapEast}&west=${mapWest}

    fetch(`http://127.0.0.1:3000/search?north=${mapNorth}&south=${mapSouth}&east=${mapEast}&west=${mapWest}`)
        .then(response => response.json())
        .then(data => {
            console.log(data);
        });
}
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