pass err and data to promise.reject and fulfill respectively