So my code is hopefully kinda straightforward (still learning don't hate me), I use a package to get the colorpallete of the image I feed it to. And since I need to wait to actually make it happen I need to wait when it's done.Well my problem is I use a then in my then, and it feels really dirty and probably is not the right way to do this. Since it's a school project I don't really mind performance on first but if somebody can give me some advice how to make this a little more usuable. And I know I return it to the next promise it doesn't make sense since it's out of the other chainI hope I kinda said it the right way haha. And if there are some articles I missed how to solve this would be great also!.then(response => { // Make copy of the response const bookObject = response // Loop through each book bookObject.forEach((book, index) => { // Find the color pallete splashy.fromUrl(book.coverImage) .then(dominantColors => { // Create new key and add it to the list bookObject[index].dominantColors = dominantColors }) }) // Pass through to the next return bookObject })
Submitted November 01, 2018 at 06:26PM by Piqant
No comments:
Post a Comment