I have stored a column as an array but when I received this from server in ionic, ionic will deal with it as a string and not array
this is how it's stored
["loca6_1.jpeg","loca6_1.jpeg"]
here is the backend function and it is written in php laravel
return Auth::user()->attachments()->pluck('filename');
and database we're using phpMyadmin
My Answer:
The issue you are facing is likely due to the way the data is being serialized and deserialized between the backend and frontend.
When you retrieve the data from the backend using `pluck('filename')`, Laravel will return an array of strings. However, when this data is sent to the frontend, it may be serialized as a string instead of an array.
To ensure that the data is treated as an array in your Ionic app, you can try parsing the string back into an array using `JSON.parse()` in your frontend code. For example:
typescript
let data = JSON.parse(responseFromBackend);
This will convert the string back into an array that you can work with in your Ionic app.
Additionally, you may want to check how the data is being sent from the backend to the frontend to ensure that it is being properly serialized and deserialized. You can also consider using a different data format, such as JSON, to avoid these issues in the future.
Rate this post
5 of 5 based on 9358 votesComments