After trying the solution from my previous question Vuex + Laravel. Why axios sends any values but only not that one, which come's with method's parameter?, I realized that it only works when passing a single argument in axios. I managed to successfully send multiple files with one argument, but in my specific case, I need to use an object in order to pass more than one argument. This is why instead of
const response = await axios.post('/posts', data)
I had to use the following approach:
const response = await axios.post('/posts', {
formData:data,
body:postBody
})
I initially thought this would be straightforward, but now I've spent 5 hours without finding a solution.
https://i.sstatic.net/3RCXn.jpg
controller
public function store(Request $request)
{
$files = $request->all();
return var_dump($files);
}
I've tried various methods including $request->allFiles() and getClientOriginalExtension(), but none of them have yielded results. Do you have any suggestions on how to fix this issue?
Important!
I'm using Laravel, Vuex, and Axios.
I cannot use FormData for text as it's inside a textarea. Even if I could combine the textarea within FormData to make a single argument axios call, it's crucial for me to understand the root cause of the problem I described above.
Updated
Here's the payload tab in Chrome: