0

i was able to get the value of response data but i cant pass it into json list. i want to set value of this.parsed data to 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'
            }
        ];

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

1 Answers1

0

A post data returns a Response object. What you want to do is change your code to take the Response's text property and then parse that as a JSON object, like so:

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