@@ -10,7 +10,7 @@ const app = express();
1010// EJS is accessed by default in the views directory.
1111app . set ( 'view engine' , 'ejs' ) ;
1212
13- // Allow access to 'public' folder
13+ // Allow access to 'public' folder where resources are available to this app
1414app . use ( express . static ( 'public' ) ) ;
1515
1616app . use ( bodyParser . urlencoded ( { extended : true } ) ) ;
@@ -27,24 +27,22 @@ app.post('/', (req, res) => {
2727 let city = req . body . locale ;
2828 let url = process . env . WEATHER_VISUALCROSSING_API_BASE_URI ;
2929
30- /* https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/Fremont%2C%20CA ?unitGroup=us&contentType=json&key=apiKey */
30+ /* https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/${city} ?unitGroup=us&contentType=json&key=${ apiKey} */
3131 let uriStr = `${ url } ${ city } ?unitGroup=us&contentType=json&key=${ apiKey } ` ;
3232 console . log ( uriStr ) ;
3333 request ( uriStr , async function ( err , response , body ) {
3434 if ( err ) {
3535 console . log ( 'error:' , err ) ;
3636 } else {
3737 let weather = await JSON . parse ( body ) . currentConditions ;
38- console . log ( weather ) ;
39-
40- // res.render('index', {locale: city, data: weather, error: null});
38+ // console.log(weather);
4139
4240 if ( weather . datetime == undefined ) {
4341 console . log ( "Something went wrong. No weather data." ) ;
4442 res . render ( 'index' , { data : null , error : 'Error, please check your input.' } ) ;
4543 } else {
46- console . log ( "currentConditions:\n" ) ;
47- console . log ( weather ) ;
44+ // console.log("currentConditions:\n");
45+ // console.log(weather);
4846 res . render ( 'index' , { locale : city , data : weather , error : null } ) ;
4947 }
5048 }
0 commit comments