# POST method only returns null (slim3)

**URL:** <https://discourse.slimframework.com/t/post-method-only-returns-null-slim3/6040>\
**Category:** Questions\
**Created:** [January 30, 2025, 3:42pm UTC](https://discourse.slimframework.com/t/post-method-only-returns-null-slim3/6040 "2025-01-30T15:42:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lcbrasil](https://avatars.discourse-cdn.com/v4/letter/l/9d8465/32.png) [@lcbrasil](https://discourse.slimframework.com/u/lcbrasil)\
**Post date:** [January 30, 2025, 3:42pm UTC](https://discourse.slimframework.com/t/post-method-only-returns-null-slim3/6040/1 "2025-01-30T15:42:09Z")

</div>

I appreciate if someone could help

GET method works fine but POST method don’t.

I used slim 3 and slim skeleton, the api is on my web page (Cpanel I´m not use localhost)

I have in src/middleware.php the following:

```php
$app->add(function ($req, $res, $next) {
    $response = $next($req, $res);
    return $response
        ->withHeader('Access-Control-Allow-Origin', '*')
        ->withHeader('Access-Control-Allow-Headers', 'X-Requested-With, Content-Type, Accept, Origin, Authorization')
        ->withHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, PATCH, OPTIONS');
});

```

in src/routes I have:

```php
use Slim\Http\Request;
use Slim\Http\Response;
use Slim\App;

$app->options('/{routes:.+}', function ($request, $response, $args) {
    return $response;
});// fim do $app->options('/{

// *******************Routes***********************
require __DIR__. '/routes/tanahoras.php';

// Catch-all route to serve a 404 Not Found page if none of the routes match
// NOTE: make sure this route is defined last
$app->map(['GET', 'POST', 'PUT', 'DELETE', 'PATCH'], '/{routes:.+}', function ($req, $res) {
    $handler = $this->notFoundHandler; // handle using the default Slim page not found handler
    return $handler($req, $res);
});// fim do $app->map(['GET',

```

in the route ‘/routes/tanahoras.php’; I have:

```php
$this->post('/tanahoras/adiciona', function (Request $request, Response $response) {
    $dados = $request->getParsedBody()['ProdutoNome'];
    $produto = Tanahora::create($dados);
    return $response->withJson($produto);
});

```
