Seems like an easy thing, but I am not getting the expected data. I want to send an array of strings to my backend and then iterate/do stuff with them.
In the frontend I have:
var jsonArray = ["String1", "String2"]
await newFile(JSON.stringify(jsonArray));
In my controller, I have:
$requestData = json_decode($request->getContent(), true);
$this->logger->info("File request data is ", [ $requestData ]);
My logger outputs:
File request data is ["[\"String1\",\"String2\"]"]
Which is not an array, but a string.
If I do it inside of php with
$txt = ["Test", "Test2"];
$json = json_encode($txt, true);
print_r(json_decode($json));
The output would be an array. Where am I going wrong or what am I missing? Having the true option in json_decode should return me my array.