JSON数据显示为Promise

时间:2018-10-23 18:05:43

标签: json python-2.7 vue.js flask promise

我的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?

response output

0 个答案:

没有答案