Something is missing for me. I tried my best to work with the API. Then I broke the URL as shown below and it works literally once. after that he did not work again. I swear I havenβt changed anything.
How do you do this in axios?
Error message - 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. 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 also tried with this modified GET, but to no avail
axios({ url: url , headers: {"Access-Control-Allow-Origin": "*"}, });
cors axios
morne
source share