looking for some solutions? You are welcome.

SOLVED: TypeError: objF.concat is not a function

Gabriel Sule:

I'm using a promise in NodeJS to execute a query, it returns an array, when I try to concatenate the first array with the second one, it returns the following error

TypeError: objF.concat is not a function

UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch().

Code

var objF = {
  album: []
};

for (var i = 0; i < response.data.length; i++) {
  if (response.data[i].name !== 'Untitled Album') {
    objF.album.push({
      id: response.data[i].id,
      name: response.data[i].name
    });
  }
}

var albumPromise = searchAlbumNext(next);

albumPromise.then(function(result) {
  var r = result;
  var union = objF.concat(r);
  res.status(200).send(union);
}, function(err) {
  res.status(400).send(err);
})

Thanks for the help



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
Share:

No comments:

Recent