반응형
Laravel API Allutive Where 절과 Vue가 작동하지 않음
내 질문은 왜 내 장소 절이 작동하지 않는가?vue(vuex) 프로젝트에서 Laravel API를 사용하고 있습니다.
여기 컨트롤러 기능이 있습니다.
public function specific_client(Request $request) {
$id = $request->id;
return JsonResource::collection(
Measurement::where('client_id', '=',$id)
->with(['clients', 'measurement_data'])->get());
}
vuetify도 사용합니다.이렇게 하면 client_id를 얻을 수 있습니다.
<v-select v-model="cnr" :items="clients" item-text="clientnumber" item-value="id" :hint="cnr" solo></v-select>
My store.js:
fetchClientMeasurements({commit}, cnr) {
axios.post("http://localhost:8000/api/clientnr", cnr)
.then(response => {
console.log(response.data.data);
console.log(cnr);
commit("setMeasurements", response.data.data);
});
},
My API Route:
Route::post('clientnr', [MeasurementController::class, 'specific_client']);
콘솔 로그 "cnr"을 실행하면 올바른 ID는 반환되지만 데이터는 반환되지 않습니다.where 절에서 $id를 치환하면 올바른 정보가 반환됩니다.내가 어디선가 저지른 멍청한 실수라고 생각하지만, 그게 내가 여기 온 이유야.
에는 엑시오스라는 .id
파라미터를 지정합니다.
axios.post("http://localhost:8000/api/clientnr", cnr)
그래야 한다
axios.post("http://localhost:8000/api/clientnr", {id: cnr})
언급URL : https://stackoverflow.com/questions/69987030/laravel-api-eloquent-where-clause-with-vue-not-working
반응형
'source' 카테고리의 다른 글
비활성화/활성화 버튼의 경우 VueJs v-if (0) | 2022.11.04 |
---|---|
MySQL 업데이트 케이스 When/THEN/ELSE (0) | 2022.11.04 |
바인드를 사용하여 추가된 이벤트 수신기를 제거하는 중 (0) | 2022.11.04 |
UTC는 서머타임을 준수합니까? (0) | 2022.11.04 |
Python 문자열이 ASCII로 되어 있는지 확인하는 방법 (0) | 2022.11.04 |