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

274
Vistas
NodeJS: Why do I keep getting Cannot GET/

I am currently trying to make a webapp that uses the darksky api to pull weather data. I have the basic functionality done, but when I try to run it on port 3000, I get "Cannot GET/". I am quite new to using node and backend servers as a whole so I don't know how to debug this. I will paste my code below.

    const express = require("express");
const unirest = require("unirest");
const credentials = require('./apiCredentials.json'); 
const app = express();
    app.use(express.static('/public')); // location of my index.html
    app.get('/weather', (req, res) => {
        const {lat,lon} = req.query;
        let request = unirest("GET",`https://${credentials.host}/${lat},${lon}`);
        request.query({
            lang:"en",
            units:"auto"
        });
        request.headers({
            "dark-sky.p.rapidapi.com": credentials.host,
            "466375f66bmsh72031b571ea7c30p1f704fjsnc527236c3565": credentials.apiKey
        });
        
        request.end(response => {
            if(response.error) res.status(500).end();
            const{
                summary,
                precipProbability,
                temperature,
                windSpeed,
                windBearing
            } = response.body.currently;
            res.status(200).send(
                JSON.stringify({
                    summary: summary,
                    chanceOfRain: precipProbability,
                    temp: temperature,
                    wind:{
                        speed: windSpeed,
                        bearing: windBearing
                    }
                })
            );
        });
    });
    app.listen(3000,()=>{
        console.info('Listening on port :3000');
    });
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