我的vue js代码
export const store = new Vuex.Store({
state: {},
getters: {
changeempdatas: (state) => {
var apidata =Vue.axios.post ('http://127.0.0.1:5000/').then( (response) => {
return response.data
});
var changeempdatas = apidata.then(function(result) {
console.log(result.empdata)
return result.empdata;
})
console.log(changeempdatas)
return changeempdatas;
}
}
});
和我的python代码
conn= pymysql.connect
(host='127.0.0.1',user='root',password='',
db='test')
class senddata(Resource):
def post(self):
curr = conn.cursor()
getdataqry = curr.execute("SELECT *
FROM `employee`")
getdatas = curr.fetchall()
#empdata = []
print "Post"
i=0
empdata = {}
for getdata in getdatas:
i += 1
empdata[i] = {}
empdata[i]['id'] = getdata[0]
empdata[i]['name'] = getdata[1]
#empdata.append({'id': getdata[0],
'name': getdata[1]})
return jsonify({'empdata': empdata})
a.close()
来自python的JSON数据未作为JSON接收,它显示为一个承诺。如何将JSON数据称为普通JSON?