Reputation: 207
This is my postman request:
http/localhost:8080/sample-market/marketAPI/1234/product/publish?productOne=testing&productTwo=checking
Can anyone help me with how to do a post call through axios. productOne & productTwo are query param & 1234 is path parameter
Upvotes: 0
Views: 1185
Reputation: 58593
I think you should read the DOC first:
From : https://www.npmjs.com/package/axios
Your given URL looks like get method:
http/localhost:8080/sample-market/marketAPI/1234/product/publish?productOne=testing&productTwo=checking
But if you still want to use POST, then here you go :
axios.post('http/localhost:8080/sample-market/marketAPI/1234/product/publish', {
productOne: 'testing',
productTwo: 'checking'
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
For GET method :
axios.get('http/localhost:8080/sample-market/marketAPI/1234/product/publish', {
params: {
productOne: 'testing',
productTwo: 'checking'
}
})
//OR direct
axios.get('http/localhost:8080/sample-market/marketAPI/1234/product/publish?productOne=testing&productTwo=checking')
Upvotes: 2