Nuxt-Axios post with header and body



Where i’m mistake?

when i make post request in some html file like that.

<script src=""></script>
        method: 'post',
        url: '',
        headers: {"token": "aspsi39393dndj383", "Content-Type": "application/json"},
        data: {
          page: 1

everything work well, it’s return me 200 ok status but when i try it in nuxt-axios via vuex store like:

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

it’s return me cors and internal server errors.


When you use async await you could just

async getProduct() {
  let product = await this.$'', )

and no need to use .then() this wouldn’t solve your answer though but i still need some hint. you could reproduce your code on here codesandbox

I would suggest to check if there is any server issue or not.


thanks but how here add headers and body ?

so if like that: im getting error:

let product = await this.$, headers: {"tboKen": "aVRmYOthfEGRmmaXDB7pow", "Content-Type": "application/json"},
                    data: {
                      page: 1