F
F
frolova_elena2018-07-17 16:32:14
Node.js
frolova_elena, 2018-07-17 16:32:14

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

2 answer(s)
S
Sergiu Mitu, 2018-07-17
@frolova_elena

If the server does not allow cross-domain requests, then nothing will work. Look towards the server.

R
RidgeA, 2018-07-17
@RidgeA

bfy.tw/J4k7

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question