大家好,我在連接到API時遇到了一個奇怪的問題。當(dāng)我使用Postman時,一切都很順利,但是如果我使用Axios提出請求,響應(yīng)是不同的。所以給你一個例子,我想得到一個id為616的客戶端;客戶await axios .post("/api/getClient", { id: 616, }).then(data => console.log(data))后端// GET CLIENTapp.post('/api/getClient', async (req, res) => { const d = await axios.get(`${baseURL}/client/account/:client_id`, { headers: headers, data: { id: req.body.id } }) res.send(d.data) res.end()});來自 axios 的響應(yīng)如下所示data: { error: false, user: { profile: null, user_addresses: [], safe_credits: 0, rating: 5 }}來自 郵遞員{ "error": false, "user": { "profile": { "id": 616, "phone_number": "07744444444", "country_code": "44", "email": "email@example.com", "first_name": "John", "last_name": "Doe", "password": null, "os": "iOS", "token": "0c9c09e7dc2f009b4cfdb2e4666ead9e", "version": "", "photo": "", "gender": "male", "registered_date": "2020-05-08T14:55:05.000Z", "enabled": 1, "socketId": "", "stripe_id": "cus_HF1eUUdada54JKN" }, "user_addresses": [], "safe_credits": 0, "rating": 5 }}
Axios VS Postman 請求獲得不同的響應(yīng)
寶慕林4294392
2022-08-18 16:14:12