{"size": 1081, "ext": "js", "max_stars_repo_path": "src/forecast.js", "max_stars_repo_name": "Musab-Nazir/WeatherApp", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/forecast.js", "max_issues_repo_name": "Musab-Nazir/WeatherApp", "max_issues_repo_issues_event_min_datetime": "2020-02-26T02:56:10.000Z", "max_issues_repo_issues_event_max_datetime": "2020-02-26T02:56:10.000Z", "max_forks_repo_path": "src/forecast.js", "max_forks_repo_name": "Musab-Nazir/WeatherApp", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 27.7179487179, "max_line_length": 370, "alphanum_fraction": 0.5948196115}
const request = require('request')

// weather request
const forecast = (lat, long, callback) => {
    const weatherURL = 'https://api.darksky.net/forecast/687e4462f8a363e9fae91bc32e610442/' + lat + ',' + long + '?units=si'
    request({
        url: weatherURL,
        json: true
    }, (error, response) => {
        if (error) {
            callback('Unable to access the weather service', undefined)
        } else if (response.body.error) {
            callback('Unable to find location', undefined)
        } else {
            const data = response.body
            // console.log(data)
            callback(undefined, data.currently.summary + ' throughout the day. It is currently ' + data.currently.temperature + '\xB0C out with a ' + data.currently.precipProbability * 100 + '% chance of precepitation. The temperature high is ' + data.daily.data[0].temperatureHigh + '\xB0C and the low is expected to be ' + data.daily.data[0].temperatureLow + '\xB0C')



        }



    })



}







module.exports = {
    forecast: forecast
}