I am doing an http call to get data from a database. There are 6 types that have to be called individually.
$scope.getAll = function() {
var url = 'http://someurl/';
varl allObjects = [];
$scope.types.forEach(element => {
http({
method: 'GET',
url: url + element.name
}).then(function successCallback(response) {
allObjects.push(response.data);
}, function errorCallback(response) {
// this doesn't apply to my issue
});
$scope.allObjects = allObjects;
}
That return like the following JSON object:
[{},
[{ "label":"myLabel",
"types": {
"source":{"url":"some url, "storage":"some storage"}}},
{ "label":"myLabel",
"types": {
"source":{"url":"some url, "storage":"some storage"}}}],[{ more objects}],[{ more objects}],],
All objects return the same structure with nested arrays. The issue I need help solving is every time it goes through an iteration of the type, it adds it as an array of objects. I need it to be added just as a new object, not an array of objects. ie:
What I am getting:
[{}, [{first iteration}], [{second iteration}], [{etc}]]
What I need:
[{first iteration}, {second iteration}, {etc}]