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

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

API在Laravel Vue中返回空數(shù)組而不是數(shù)據(jù)

API在Laravel Vue中返回空數(shù)組而不是數(shù)據(jù)

PHP
猛跑小豬 2022-07-16 11:09:36
我正在為學校做一個 Laravel Vue 項目,我應該通過從客戶端發(fā)送電子郵件來獲取用戶,但是當服務器響應時,我從響應數(shù)據(jù)中得到一個空數(shù)組,而不是我想要從數(shù)據(jù)庫中獲取的數(shù)據(jù)。登錄.vuelogin() {        this.showMessage = true;        this.typeofmsg = "alert";        this.message = "Loggin in...";        axios.post('api/login', this.user)            .then(response => {                const token = response.data.access_token;                this.$store.commit('setAccessToken', token);                return axios.get('api/users/me', this.user.email);            })            .then(response => {                console.log(response);            })            .catch(error => {                console.log("Error = " + error.message);            });    },路線/api.jsRoute::get('users/me', 'UserControllerAPI@myProfile');用戶控制器APIpublic function myProfile(Request $request){    $email = $request->email;    $user = User::where('email', $email)->first();    return new UserResource($user);}如果我嘗試使用郵遞員獲取它,它可以工作在開發(fā)工具控制臺中我得到了這個抱歉,如果我不清楚,或者它是錯誤的,我從昨天開始一直在嘗試解決這個問題,這讓我發(fā)瘋了。任何幫助表示贊賞編輯:路線錯誤,但我改變了它,我得到了相同的,沒有數(shù)據(jù)。我也更改了控制臺圖片
查看完整描述

2 回答

?
絕地無雙

TA貢獻1946條經驗 獲得超4個贊

更改此行:

return axios.get('api/users/me', this.user.email);

return axios.get('api/users/me', { params: { email: this.user.email } });


查看完整回答
反對 回復 2022-07-16
?
jeck貓

TA貢獻1909條經驗 獲得超7個贊

你有 api/user/me 并且在路由中你有 /userS/me

所以我想您必須在其中一個位置刪除 S 或添加 S 。

所以嘗試改變路線

Route::get('users/me', 'UserControllerAPI@myProfile');

Route::get('/user/me', 'UserControllerAPI@myProfile');


查看完整回答
反對 回復 2022-07-16
  • 2 回答
  • 0 關注
  • 151 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號