Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
31 changes: 31 additions & 0 deletions Web-Programming/OpenWeatherMaps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const fetch = require('node-fetch')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about this requirement,
we can add a common package.json file which can be used to install all requirements using
npm install

and please remove package-lock.json file
thank you @ruppysuppy

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and please add a global package.json file

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added a global package.json file and removed package-lock.json but the HeapSort was causing some issues, I didn't touch it but it was modified by itself.


const APPID = '' // <-- Put your OpenWeatherMap appid here!
const URL_BASE = 'http://api.openweathermap.org/data/2.5/'

async function currentWeather (location) {
const response = await fetch(`${URL_BASE}weather?q=${location}&appid=${APPID}`)
const data = await response.json()
return data
}

async function weatherForecast (location) {
const response = await fetch(`${URL_BASE}forecast?q=${location}&appid=${APPID}`)
const data = await response.json()
return data
}

async function oneCallApi (latitude, longitude) {
const response = await fetch(`${URL_BASE}onecall?lat=${latitude}&lon=${longitude}&appid=${APPID}`)
const data = await response.json()
return data
}

currentWeather('Kolkata')
.then(data => console.log(data))

weatherForecast('Kolkata')
.then(data => console.log(data))

oneCallApi(55.68, 12.57)
.then(data => console.log(data))
13 changes: 13 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "javascript",
"version": "1.0.0",
"description": "A repository for All algorithms implemented in Javascript (for educational purposes only)",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "TheAlgorithms",
"license": "GPL-3.0",
"dependencies": {
"node-fetch": "2.6.0"
}
}