Answer the question
In order to leave comments, you need to log in
How to properly write an axios request with a CORS header?
I wrote this code under axios to get elements from the backend in C # (ASP.NET), but the request is blocked with the justification that the request lacks the request header "No 'Access-Control-Allow-Origin' header is present on the requested resource" .
const BaseURL = "http://localhost:5142/api/";
// Получить все элементы меню
export default function GetAllNews() {
let answer = []
axios.get(BaseURL + "News/get-all")
.then(response => {
answer = response.data
})
.catch(e => console.log(e))
return answer;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question