# Group Middleware error

**URL:** <https://discourse.slimframework.com/t/group-middleware-error/4056>\
**Category:** Questions\
**Created:** [April 15, 2020, 8:45am UTC](https://discourse.slimframework.com/t/group-middleware-error/4056 "2020-04-15T08:45:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![SVL](https://avatars.discourse-cdn.com/v4/letter/s/848f3c/32.png) [@SVL](https://discourse.slimframework.com/u/SVL)\
**Post date:** [April 15, 2020, 8:45am UTC](https://discourse.slimframework.com/t/group-middleware-error/4056/1 "2020-04-15T08:45:11Z")

</div>

Using the Group Middleware example from [http://www.slimframework.com/docs/v4/concepts/middleware.html](http://www.slimframework.com/docs/v4/concepts/middleware.html) throws this error:

**Fatal error** : Uncaught TypeError: Return value of Slim\Handlers\Strategies\RequestResponse::\_\_invoke() must implement interface Psr\Http\Message\ResponseInterface, int returned

What is the fix to this error?

---

<div class="post-metadata">

**Author:** ![odan](https://avatars.discourse-cdn.com/v4/letter/o/9de053/32.png) [@odan](https://discourse.slimframework.com/u/odan)\
**Post date:** [April 15, 2020, 9:39am UTC](https://discourse.slimframework.com/t/group-middleware-error/4056/2 "2020-04-15T09:39:35Z")

</div>

Only this code could cause the error you mentioned:

```php
return $response->getBody()->write('data');

```

Edit:

~~I didn’t find it in the documentation. Where exactly did you find it?~~

I found it here.

```php
$app->get('/', function (Request $request, Response $response) {
    return $response->getBody()->write('Hello World');
});

```

Replace it with this code:

```php
$app->get('/', function (Request $request, Response $response) {
    $response->getBody()->write('Hello World');
    return $response;
});

```

This page will be fixed soon: [https://github.com/slimphp/Slim-Website/pull/497](https://github.com/slimphp/Slim-Website/pull/497)

---

<div class="post-metadata">

**Author:** ![SVL](https://avatars.discourse-cdn.com/v4/letter/s/848f3c/32.png) [@SVL](https://discourse.slimframework.com/u/SVL)\
**Post date:** [April 15, 2020, 10:21am UTC](https://discourse.slimframework.com/t/group-middleware-error/4056/3 "2020-04-15T10:21:25Z")

</div>

Thanks for the fix Odan.
