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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

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

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

PHP
猛跑小豬 2022-07-16 11:09:36
我正在為學(xué)校做一個(gè) Laravel Vue 項(xiàng)目,我應(yīng)該通過(guò)從客戶(hù)端發(fā)送電子郵件來(lái)獲取用戶(hù),但是當(dāng)服務(wù)器響應(yīng)時(shí),我從響應(yīng)數(shù)據(jù)中得到一個(gè)空數(shù)組,而不是我想要從數(shù)據(jù)庫(kù)中獲取的數(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');用戶(hù)控制器APIpublic function myProfile(Request $request){    $email = $request->email;    $user = User::where('email', $email)->first();    return new UserResource($user);}如果我嘗試使用郵遞員獲取它,它可以工作在開(kāi)發(fā)工具控制臺(tái)中我得到了這個(gè)抱歉,如果我不清楚,或者它是錯(cuò)誤的,我從昨天開(kāi)始一直在嘗試解決這個(gè)問(wèn)題,這讓我發(fā)瘋了。任何幫助表示贊賞編輯:路線錯(cuò)誤,但我改變了它,我得到了相同的,沒(méi)有數(shù)據(jù)。我也更改了控制臺(tái)圖片
查看完整描述

2 回答

?
絕地?zé)o雙

TA貢獻(xiàn)1946條經(jīng)驗(yàn) 獲得超4個(gè)贊

更改此行:

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

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


查看完整回答
反對(duì) 回復(fù) 2022-07-16
?
jeck貓

TA貢獻(xiàn)1909條經(jīng)驗(yàn) 獲得超7個(gè)贊

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

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

所以嘗試改變路線

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

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


查看完整回答
反對(duì) 回復(fù) 2022-07-16
  • 2 回答
  • 0 關(guān)注
  • 138 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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