After receiving an API response's data,
[{id: 1, name:"Test 1"},{id: 2, name:"Test 2"}]
I am working on my component .vue file.
...
created() {
const request = axios.get("***api_url***").then(response => {
const result = response.data;
const placeholder = { 'id': 0, 'name': '[Select]' };
const newObject = result.concat( placeholder.map( item => ({id: item.id, name: item.name}) ) );
console.log(newObject);
});
}
The goal is to combine the placeholder object with the API response data.