@frolova_elena

Oшибка при 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>
  • Вопрос задан
  • 756 просмотров
Решения вопроса 1
EaGames
@EaGames
Front-end developer
Если сервер не разрешает кроссдоменные запросы то ничего работать не будет. Смотрите в сторону сервера.
Ответ написан
Комментировать
Пригласить эксперта
Ответы на вопрос 1
@RidgeA
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы