带有标题和正文的Nuxt-Axios帖子

时间:2019-01-13 14:35:59

标签: axios nuxt.js

我错了,

当我在类似的html文件中发出发布请求时。

<head>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
</head>
<body>
    <script>
        axios({
        method: 'post',
        url: 'http://some.com/some/',
        headers: {"token": "aspsi39393dndj383", "Content-Type": "application/json"},
        data: {
          page: 1
        }
      });
    </script>
</body>

一切正常,它返回200 ok的状态,但是当我通过vuex存储在nuxt-axios中尝试它时:

await this.$axios.post('http://some.com/some/', {headers: {"token": "aspsi39393dndj383", "Content-Type": "application/json"},
                    data: {
                      page: 1
                    }}).then(response => {
                        // If request is good...
                        console.log(response.data);
                      })
                      .catch((error) => {
                        console.log('error 3 ' + error);
                      });

它返回了我的错误和内部服务器错误。

0 个答案:

没有答案