Answer the question
In order to leave comments, you need to log in
What am I doing wrong when accessing the server?
I broke my head, I don’t understand ... I
execute a request from the vue axios post component
The server processes it like this:
var bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({extended:false}));
app.use(bodyParser.json());
app.post('/punycode', (req, res) => {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Methods", "GET, PUT, PATCH, POST, DELETE");
res.header("Access-Control-Allow-Headers", "Content-Type");
console.log(req.body);
});
var postData = {
type: 'text',
pdata: this.text
}
const str = JSON.stringify(postData);
//передается str
[Object: null prototype] { '{"type":"text","pdata":"Введите текст"}': '' }
var postData = {
type: 'text',
pdata: this.text
}
import axios from 'axios'
var domen = 'localhost'
export default() => {
return axios.create({
baseURL: '//' + domen + ':3000'
})
}
import Api from '@/services/Api'
export default {
Pr (params) {
return Api().post('abc', params)
},
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question