CICCIOSGAMINO / openweather-apis

Simple APIs for OpenWeatherMap.org basic services
GNU General Public License v3.0
44 stars 27 forks source link

XMLHttpRequest cannot load <url> #15

Closed DuckThom closed 8 years ago

DuckThom commented 8 years ago

Chrome dev console:

XMLHttpRequest cannot load http://api.openweathermap.org/data/2.5/weather?q=groningen&units=metric&lang=en&mode=json&APPID=XXX. A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin' header when the credentials flag is true. Origin 'http://localhost:8080' is therefore not allowed access. The credentials mode of an XMLHttpRequest is controlled by the withCredentials attribute.

Code (VueJS):

import Weather from 'openweather-apis'

Weather.setLang('en')
Weather.setUnits('metric')
Weather.setCity('Groningen')
Weather.setAPPID('XXX')

Weather.getTemperature(function (err, temp) {
    if (err) console.log(err)

    console.log(temp)
})
DuckThom commented 8 years ago

I did some testing and it looks like this can be fixed by adding withCredentials: false to the request options.