This project is an asynchronous web app that uses Web API and user data to dynamically update the UI using Node Express and asynchronous JavaScript.
In this app the user seclects country and enters the ZIP Code of the area to get temperature in and enters feelings about the weather and after that presses the "Generate" button. The UI is updated and displays date, temperature and the user's feelings.
This project has 2 JavaScript files server.js
file and website/app.js
file.
The server.js
file contains the local server side code and has GET and POST routes app.get('/getData', returnProjectData);
, app.post('/postData', addToProjectData)
;.
The website/app.js
file has an event listener to the Generate button and when the user clicks the button it goes to returnResultToUser()
function which saves the ZIP Code, country, and feelings values that user enters and then calls getTemprature(baseURL, countryCode, zip, key, units)
to get the temperature from OpenWeatherMap API, then after the temperature is returned it calls the postData
function to make a POST request to the local server and saves the data in projectData
object in server.js
and then it calls changeUI('/getData')
to get data from server and then change the UI.
- Shorouk Elkhateeb