I am trying to understand promises, it appears as if all promises I have looked at in examples follow a waterfall pattern, where the results of the previous function are passed to the .then function, and the results of that function are passed to the .then function again and again.
What if I need to do certain things in a certain order, but the next function doesn't count on the output of the previous promise?
const obj = {
key1: value1,
key2: value2
};
const files = ['file1', 'file2', 'file3'];
Promise.all(files.map(makeBackups))
.then(
// use obj to create new strings to be inserted into orig files after they were backed up - Could be done at same time orig files are being backed up
)
.then(
// write to files now that they have a backup and content to be written
)
.catch(
// something happened when trying to write a file.
)
What am I missing?