fetch http request err 500

Hey,
After finishing with the updating the collection, you should return the relevant value. It seems like you’ve returned the promise but inside the “then” part you haven’t returned anything.
If it’s unclear, paste here the rest of the code and I’ll try to explain it better with your code.
Moreover, as Andreas mentioned, I recommend splitting the code to smaller functions. It will help you with debugging your code.

Good luck,
Tal.