Closed pishguy closed 3 years ago
with this package i try to use post method for a single route, but in laravel side i get 'undefined for data
laravel
'undefined
route:
Route::prefix('{language}')->middleware(['setLanguage'])->group(function () { Route::prefix('panel')->group(function () { Route::get('/user-profile', UserProfileController::class)->name('user-profile'); }); });
route.js
const routes = { // "update_profile": { "uri": "{language}\/panel\/update_profile" }, // }; //...
vuejs axios impleemntation:
axios
let formData = new FormData(); formData.append('name', this.name) formData.append('family', this.family) formData.append('website', this.website) formData.append('telegram_id', this.telegram_id) formData.append('instagram_page', this.instagram_page) formData.append('avatar', this.avatar) axios.post(route('update_profile'), formData, { headers: {"Content-Type": "multipart/form-data"}, }).then((result) => { console.log(result); }).catch((error) => { console.log(error); })
and output which laravel return for me:
Illuminate\Http\JsonResponse {#772 #data: ""undefined"" #callback: null #encodingOptions: 0 +headers: Symfony\Component\HttpFoundation\ResponseHeaderBag {#777 #computedCacheControl: array:2 [ "no-cache" => true "private" => true ] #cookies: [] #headerNames: array:3 [ "cache-control" => "Cache-Control" "date" => "Date" "content-type" => "Content-Type" ] #headers: array:3 [ "cache-control" => array:1 [ 0 => "no-cache, private" ] "date" => array:1 [ 0 => "Sat, 03 Apr 2021 04:16:12 GMT" ] "content-type" => array:1 [ 0 => "application/json" ] ] #cacheControl: [] } #content: ""undefined"" #version: "1.0" #statusCode: 200 #statusText: "OK" #charset: null +original: "undefined" +exception: null }
laravel controller action:
public function update_profile(Request $request) { dd(response()->json($request->input('avatar'))); }
error:
Missing parameters
In this line you should add the language key, or an extra parameter, remember that this function behaves as route function
axios.post(route('update_profile', {"language": "en"}), formData, {
with this package i try to use post method for a single route, but in
laravel
side i get'undefined
for dataroute:
route.js
vuejs
axios
impleemntation:and output which
laravel
return for me:laravel
controller action:error: