modules: [
‘@nuxtjs/proxy’,
],
/* ‘/backend’ will be replaced by ‘http://localhost:18080’ */
proxy: {
‘/backend’: {
target: ‘http://localhost:18080',
pathRewrite: {
‘^/backend’: ‘/’,
},
},
},
/* Real call http://localhost:18080/claim */
async saveClaim(claim) {
let response = {};
response = await this.$axios.post('/backend/claim', claim);
$log(response);
},
For a CURL like this:
curl \
-X POST \
-d name=Cristina \
-d surname=Fernandez \
"URL"
The axios way would be:
try {
const params = new URLSearchParams();
params.append("name", this.form.name);
params.append("surname", this.form.surname);
const response = await this.$axios.$post(
"URL",
params
);
...
} catch (e) {
this.errorSend = true;
}