I'm missing something here. I was struggling to get the API call to work. Then I split the url up like below and it works -literally once. After that it fails to work again. I swear I did not change something.
How do you go about it in AXIOS?
Error message is:
XMLHttpRequest cannot load http://magicseaweed.com/api/W2Z26fXscpELi7nPB0svfqcGj9FtGO9e/forecast/?spot_id=228. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.
import axios from 'axios';
const ROOT_URL = `magicseaweed.com/api/W2Z26fXscpELi7nPB0svfqcGj9FtGO9e/forecast/`;
export const FETCH_WEATHER = 'FETCH_WEATHER';
export function fetchWeather() {
const url = `http://${ROOT_URL}?spot_id=228`;
const request = axios.get(url);
return {
type: FETCH_WEATHER,
payload: request
};
}
I tried with this modified GET aswell, but to no avail
axios({
url: url ,
headers: {"Access-Control-Allow-Origin": "*"},
});