i doing tutorial on react reflux. im getting 404 on query response. think has todo url
sent fetch data.
when console.log on variable 'url' following:
api.openweathermap.org/data/2.5/forecast?appid=4e26b7e43fe918dbc620bbf34456a9de&q=new york,us
in network request tab see following in request
request url:http://localhost:8080/api.openweathermap.org/data/2.5/forecast?appid=4e26b7e43fe918dbc620bbf34456a9de&q=new%20york,us request method:get status code:404 not found remote address:127.0.0.1:8080
if copy address , paste address bar, sure thing dont respons, if delete localhost:8080
address, perfect response api.
why localhost:8080
being added, , if wrong how fix it?
here action created go , fetch data.
action:
import axios 'axios'; const api_key = '4e26b7e43fe918dbc620bbf34456a9de'; const root_url = `api.openweathermap.org/data/2.5/forecast?appid=${api_key}`; export const fetch_weather = 'fetch_weather'; export function fetchweather(city) { var url = `${root_url}&q=${city},us`; const request = axios.get(url); return { type: fetch_weather, payload: request }; }
this worked, can explain why maybe?
on url variable, manually added http://
, caused url request not prepend http://localhost:8080
import axios 'axios'; const api_key = '4e26b7e43fe918dbc620bbf34456a9de'; const root_url = `api.openweathermap.org/data/2.5/forecast?appid=${api_key}`; export const fetch_weather = 'fetch_weather'; export function fetchweather(city) { var url = `http://${root_url}&q=${city},us`; const request = axios.get(url); return { type: fetch_weather, payload: request }; }