第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

錯誤:請求失敗,狀態(tài)碼為 400。在 POSTMAN 和應(yīng)用程序中發(fā)送之間的差異

錯誤:請求失敗,狀態(tài)碼為 400。在 POSTMAN 和應(yīng)用程序中發(fā)送之間的差異

喵喵時光機(jī) 2021-08-20 15:29:47
在郵遞員它工作:1) url: https://app/login2) method: POST3) body4) x-www-form-urlencoded5)username: ****,password: ****,grant_type: 'password',client_secret: '****',client_id: '****'在函數(shù)submit方法POST中,當(dāng)表單提交時,它不起作用。我有錯誤:xhr.js?b50d POST https://app/login 400(錯誤請求)錯誤:在 XMLHttpRequest.handleLoad (xhr.js?b50d) 處的 createError (createError.js?2d83) 處,請求失敗,狀態(tài)碼為 400 (settle.js?467f)在選項(xiàng)卡Network中response我有:{"error":"invalid_client","error_description":"在標(biāo)題或正文中找不到客戶端憑據(jù)"}登錄class Login extends Component {  constructor (props) {    super(props);    this.state = {      email: '',      password: ''    }  }  handle = (e) => {    const name = e.target.name;    const value = e.target.value;    this.setState({      [name]: value    });  }  submit = (event) => {    event.preventDefault();    const body1 = {      username: this.state.email,      password: this.state.password,      grant_type: 'password',      client_secret: '****',      client_id: '****'    }    axios({       method: 'post',       url: 'https://app/login',       body: body1,       headers: {        'Content-Type': 'application/x-www-form-urlencoded'      }      })       .then(res => {         if (res.status === 200) {          console.log(res)        }       }).catch(err => {         console.error(err);      });  }  render () {    return (      <form action="" method="post" onSubmit={this.submit}>        <div>          <label htmlFor="email">Email</label>          <input type="email" required  name="email"            value={this.state.email}            onChange={this.handle}  />        </div>        <div>          <label htmlFor="password">Password</label>          <input type="password"name="password"            value={this.state.password}            onChange={this.handle}  />        </div>        <button type="submit" value="Submit">Log</button>      </form>    )  }}在 POSTMAN 中發(fā)送和在應(yīng)用程序中發(fā)送有什么區(qū)別?正文內(nèi)容轉(zhuǎn)換為字符串?
查看完整描述

3 回答

?
慕俠2389804

TA貢獻(xiàn)1719條經(jīng)驗(yàn) 獲得超6個贊

代碼在 Content-Type 中聲明主體將是 URL 字符串編碼的,但在主體中它被賦予了一個 JavaScript 對象。似乎 Axios 客戶端不會將該 body 對象轉(zhuǎn)換為 url 編碼值(即 from?{a: 5, b: 2}to?"a=5&b=2")。代碼需要一個函數(shù)來轉(zhuǎn)換它。一個流行的是qs。

否則,您的數(shù)據(jù)可能會被轉(zhuǎn)換為字符串,該.toString()方法將為您提供"[object Object]",您應(yīng)該能夠在開發(fā)人員工具的網(wǎng)絡(luò)選項(xiàng)卡中看到這一點(diǎn)。


查看完整回答
反對 回復(fù) 2021-08-20
?
慕姐8265434

TA貢獻(xiàn)1813條經(jīng)驗(yàn) 獲得超2個贊

Axios 處理錯誤的方式不同。

找出真正的問題所在。

您應(yīng)該使用 error.request 來檢查您提出的請求是否有錯誤

并使用 error.response 從服務(wù)器獲取錯誤反饋

axios({ method: 'post', url: 'https://app/login', body: body1, headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }) .then (res => { if (res.status === 200) { console.log(res) } }).catch(err => { if(err.request){ console.log(err.request) } if( err.response){ console.log(err.response) } });


查看完整回答
反對 回復(fù) 2021-08-20
?
泛舟湖上清波郎朗

TA貢獻(xiàn)1818條經(jīng)驗(yàn) 獲得超3個贊

Localhost:3000/api/products 404 錯誤 您沒有在 server.js 上創(chuàng)建 res.get("/api/products") 或者您沒有設(shè)置代理。檢查下面的代理設(shè)置。

代理錯誤:無法代理請求 /api/products 檢查:

  1. 前端/package.json

    { "name": "frontend", "proxy": "http://127.0.0.1:5000", ... }

  2. 停止運(yùn)行前端和后端

  3. 先運(yùn)行后端

    啟動

  4. 然后前端

    cd 前端 npm start


查看完整回答
反對 回復(fù) 2021-08-20
  • 3 回答
  • 0 關(guān)注
  • 446 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號