I am making a post request through laravel-vue on the browser and I am getting a 401, but it works on postman with the exact headers & paramaters

this is the function that is triggered once the form button is clicked

      add_book: function(){
          axios.post('http://127.0.0.1:8000/api/v1/books', {
            headers: {
            'Content-Type': 'application/json',
            'Accept': 'application/json',
            'Authorization': 'Bearer' this.token,
            },
            params: {
                'name': this.name,
                'description': this.description,
                'publication_year': this.publication_year,
            }

            }).then((response => {
                if (response.status == 201){
                    this.name = "";
                    this.description = "";
                    this.publication_year = "";
                    console.log('a new book is added');
                }
            })).catch((error) => {
                console.log(error);
        });
        console.log(this.name);
      }
  }

and this is the vs_code thunder client (an extension that works like postman) request.

enter image description here post request on vs code enter image description here



from Recent Questions - Stack Overflow https://ift.tt/3qXkNbm
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation