面對這個問題,我被困了 4 個小時。我有這個代碼var sttr = []; this.$http .post(this.api_url+url, data) .then((response)=>{ sttr.push(response.data); }) .catch((error)=>{ if(error.request.status == 401){ this.unauth(); }else{ sttr.push(error.response.data.errors); } }); console.log(sttr[0]);我對成功和錯誤的響應都存儲在 sttr 變量中。但問題是當我想獲取數組的第一個值時,它返回未定義的值。那么,有沒有辦法解決這個問題?
如何從 axios 響應中獲取數組值
鴻蒙傳說
2021-08-20 17:38:25
