I've got an AWS call that looks like this:
ecs.describeServices(params, function(err, data) {
   if (err) {
      return { data: '',success: false };
   } else {
      return { data: 'whohoo',success: true};
   }
});
This is in a method that needs to return a promise that resolves to my return object.
I've been experimenting with this type solution, but just can't figure it out.
        var keepsHisWord;
        keepsHisWord = true;
        var promise1 = new Promise(function(resolve, reject) {
            if (keepsHisWord) {
                resolve({ mytest: "mytest101" });
            } else {
                reject("The man doesnt want to keep his word");
            }
        });
Edit: Working. Thanks to the two people who posted. That really helped a lot. And wondering why the question down-voted. I did a bunch of research first. I guess just not as smart at the down-voter.
            var promise1 = function(params) {
            return new Promise(function(resolve, reject) {
                ecs.describeServices(params, function(err, data) {
                    if (err) {
                        resolve({
                            error: "my error"
                        });
                    } else {
                        resolve({
                            runningCount: data.services[0].runningCount,
                            pendingCount: data.services[0].pendingCount,
                            status: data.services[0].status,
                            desiredCount: data.services[0].desiredCount,
                            createdAt: data.services[0].desiredCount,
                            events: data.services[0].events
                        });
                    }
                });
            });
        };
        return promise1(params);
 
     
    