- 
                Notifications
    You must be signed in to change notification settings 
- Fork 97
Open
Description
The SparkPostPromise::then function does not return the result of the callback functions. This means the new promise that it returns will have no data.
$result = $sparky->request(...)->then(function($response) {
  // do something
  return $response;
})->wait();
// $result is now null!This is important if we want to add our own middleware to transform the response.
SparkPostPromise::then could be restructured like this to fix the issue (happy to open a PR if this is suitable):
    public function then(callable $onFulfilled = null, callable $onRejected = null)
    {
        $request = $this->request;
        return $this->promise->then(function ($response) use ($request) {
            return new SparkPostResponse($response, $request);
        }, function ($exception) use ($request) {
            return new SparkPostException($exception, $request)
        })->then($onFulfilled, $onRejected);
    }Metadata
Metadata
Assignees
Labels
No labels