Answer the question
In order to leave comments, you need to log in
Error with axios post?
Failed to load http://xxx.xxx.x: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access.
<code>createError.js:16 Uncaught (in promise) Error: Network Error
at createError (createError.js:16)
at XMLHttpRequest.handleError (xhr.js:87)
</code>
Вот запрос
<code><template>
<div>
</div>
</template>
<script>
import axios from 'axios'
export default {
methods: {
test() {
axios.post("http://xxx.xx.xx",{ headers: { 'Access-Control-Allow-Origin': true }} )
.then((res) => {
console.log(res);
return {res}
})
}
},
mounted() {
return this.test()
}
}</code>
Answer the question
In order to leave comments, you need to log in
If the server does not allow cross-domain requests, then nothing will work. Look towards the server.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question