nafeeur10's avatar

Getting [Object object] for Axios Request.

I want to update my data with axios.

Axios.post('/api/data/user/updateInstructor', {
	id: editInstructor[index].id,
	name: editInstructor[index].name,
	email: editInstructor[index].email,
	phone_number: editInstructor[index].phone_number,
	country: editInstructor[index].country
	}).then((res)=>{
		console.log("Updated!" + res);
	}).catch((err)=>{
		console.log("Problem");
});

But while I am just return the $request it is giving me error!!

function instructorUpdate(Request $request) {
        return $request;
    }

This is giving Updated![object Object]. What is the problem?

0 likes
1 reply
MichalOravec's avatar
Level 75

It's not error. You are trying to print out object as a string.

Instead of

return $request;

do

return $request->all();

and change this

console.log("Updated!" + res);

to

console.log('Updated!', res);

Please or to participate in this conversation.