我收到来自API的响应,但无法访问此响应中数组的位置。
fileTransfer.upload(this.imageURI, environment.restUrl + "Upload/addIonic", options)
.then(data => {
console.log('data');
console.log(JSON.stringify(data));
let response;
console.log('bytesSent');
console.log(data.bytesSent);
response = data.response
console.log('response');
console.log(response);
console.log('response[0]');
console.log(response[0]);
});
控制台返回:
console.log: bytesSent
[19:51:03] console.log: 1168539
[19:51:03] console.log: response
[19:51:03] console.log:
[{"fd":"445bcc46-ad55-4079-95d0-9b0deaab7c4c","size":1168430,"type":"image/jpeg","filename":"ionicfile","status":"finished","field":"ionicfile","extra":{"Location":"https://easy-move.s3.amazonaws.com/445bcc46-ad55-4079-95d0-9b0deaab7c4c","Bucket":"easy-move","Key":"445bcc46-ad55-4079-95d0-9b0deaab7c4c","ETag":"\"69ede2190589f905ee8590446caf1cf7-1\"","size":1168430}}]
[19:51:03] console.log: response[0]
[19:51:03] console.log: [
相反,返回一个对象,数组在零位置返回“[”。