我正在使用請求包發(fā)送一個 post 請求以獲取 authToken,然后一個 get 請求以獲取 parcel 對象數(shù)組,這樣我就可以將它發(fā)送到我的應(yīng)用程序的其余部分。當我記錄 body.parcels 時,它顯示了幾個 [Object, Object] 項目。我看不到這些對象中的數(shù)據(jù),所以我很難弄清楚數(shù)據(jù)是什么。var options = { uri: 'https://api.onetracker.app/auth/token', method: 'POST', json: { email: this.config.username, password: this.config.password, }, }; request(options, function (error, response, body) { if (!error && response.statusCode == 200) { const authToken = body.session.token; const options = { uri: 'https://api.onetracker.app/parcels', method: 'GET', json: true, headers: { 'x-api-token': authToken, }, }; request(options, function (error, response, body) { if (!error && response.statusCode == 200) { let result = body.parcels; console.log('Result: ' + result); // check this.sendSocketNotification('ONETRACKER_RESULT', result); } }); }
請求正文記錄為 [Object Object],我無法從中獲取數(shù)據(jù)
慕的地6264312
2023-04-27 16:29:08