I am currently working on displaying and sorting data in a bootstrap table within VueJS.
My goal is to change the date format within an array retrieved from an API endpoint. The original date format is in "January 21, 2010" and I need it to be in "MM/DD/YYYY" format for proper sorting in the bootstrap table. Each cell in the table consists of multiple values that are concatenated together. While mapping the array, I used the join function for most fields but for the date field, which always contains a single value, I wanted to create a custom function to convert the date format (e.g., January 21, 2010 to 01/21/2010) directly in the methods section rather than using the join method.
However, when I tried declaring this function in the methods section, I encountered the following error: [Vue warn]: Error in render: "TypeError: item.LastUpdatePostDate.newFunction is not a function" How can I resolve this issue? Is there a more efficient way to handle the date format conversion?
computed: {
mappedItems() {
return this.items.map((item) => {
return {
Ids: item.Ids.join(""),
Acronyms: item.Acronyms.join(", "),
LastUpdatePostDate: item.LastUpdatePostDate.newFunction(),
};
});
},
},
methods: {
newFunction: function () {
return arguments
},}