javascript - "Object of class SymfonyComponentHttpFoundationParameterBag could not be converted to string" - What does this error mean and how can I fix it
Get the solution ↓↓↓I'm currently creating an application using the Laravel framework and Vue JS.
I have a lot of different 'statuses' e.g. CEO, COO, CFO, Accountant etc. and they all have an ID and a stage_id. My end goal is to use their unique IDs to get their stage IDs and then update their stage IDs to be the same
IMPORTANT: THE $request coming in is in the form of an array of the various status IDs so it could be something like [1,4,6] or even []
This is my controller function:
public function updateStatuses(Request $request, Stage $stage)
{
foreach($request as $statusId) {
Status::forClient()->findOrFail($statusId)->update([
'stage_id' => $stage->id,
]);
}
Status::forClient()->all();
return Status::all();
}
My axios request:
changeStatusIds() {
var self = this;
axios.put(window.routes["statusroute"].replace('{stage}', this.selectedStage.id), this.selectedStatuses)
.then(function (response) {
console.log(response);
self.allStatuses = response.data;
})
.catch(function(error){
console.error(error);
if (!!error.response) console.log(error.response);
});
},
However, I keep getting the error "Object of class Symfony\Component\HttpFoundation\ParameterBag could not be converted to string" which I've never come across before and can't seem to debug. Given my current code, how can I fix this?
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: string literal contains an unescaped line break
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.