【问题标题】:cant pass response data to JSON [duplicate]无法将响应数据传递给 JSON [重复]
【发布时间】:2018-07-08 14:07:59
【问题描述】:

我能够获取响应数据的值,但我无法将其传递到 json 列表中。我想将 this.parsed 数据的值设置为 response.data

this.parsedData = [
            {   
                employeeName: 'Frances Adiova',
                psid: '31449',
                region: 'APAC',
                subRegion: 'SEA',
                role: 'CAM',
                year: '2018'
            },
            {
                employeeName: 'Julien Nicolas',
                psid: '28313',
                region: 'APAC',
                subRegion: 'SEA',
                role: 'RAM',
                year: '2018'
            }
        ];

我有这个this.axios.post(store.state.backendEndpoint + '/ImportExport/Import', formData,{ headers: { 'Content-Type': 'multipart/form-data' } } ).then(function(response){ this.parsedData = response.data;
})

【问题讨论】:

    标签: asp.net-core vue.js vuetify.js


    【解决方案1】:

    发布数据返回一个响应对象。您要做的是更改代码以获取响应的 text 属性,然后将其解析为 JSON 对象,如下所示:

    this.axios.post(store.state.backendEndpoint + '/ImportExport/Import',
                formData,{
                    headers: {
                        'Content-Type': 'multipart/form-data'
                    }
                }
                ).then(function(response){
                    this.parsedData = JSON.parse(response.text());
                });
    

    【讨论】:

    • 谢谢。但我已经试过这个了。结果还是一样
    猜你喜欢
    • 1970-01-01
    • 2019-11-25
    • 2018-01-18
    • 1970-01-01
    • 1970-01-01
    • 2019-03-25
    • 1970-01-01
    • 2018-09-01
    • 1970-01-01
    相关资源
    最近更新 更多