# How do I pass data to a response?

The most common task performed when extending responses, is setting additional data. Typically, for HTML responses that render from a view, this involves sending data to the view to be used as a variable. If the response returns JSON, it may be adding additional key/value pairs.

For example, if you needed to obtain customer reviews for a given product and output them on the product page, you could do the following, which passes a product to a 3rd party reviews API and then adds the reviews it returns to the response data, which is then passed to the `product.twig` view file ready to be loop around and outputted:

```php
\Aero\Store\Http\Responses\ProductPage::extend(function (\Aero\Store\Http\Responses\ProductPage $page, \Closure $next) {
    $reviews = ReviewsAPI::forProduct($page->product);

    $page->setData('reviews', $reviews);

    return $next($page);
});
```

Another example is getting the latest 5 blog posts from a blog module and sending them to the homepage to be displayed:

```php
\Aero\Store\Http\Responses\Homepage::extend(function (\Aero\Store\Http\Responses\ProductPage $page, \Closure $next) {
    $posts = \Acme\BlogPosts::latest()->limit(5)->get();

    $page->setData('posts', $posts);

    return $next($page);
});
```

<p class="callout info">You can obtain the existing data set against the response builder using the `getData()` method.</p>

<p class="callout info">You can remove existing data set against the response builder using the `removeData()` method.</p>