API Action event return with duplicate response

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
rembo
User
Posts: 227

API Action event return with duplicate response

Post by rembo »

Hello ,, I have two API action like this (2024.7)

// API Action event
function Api_Action($app)
{
    // Example:
    $app->post('/myaction', function ($request, $response, $args) {
        return $response->withJson(["name" => "myaction"]); 
     });
    $app->post('/myaction2', function ($request, $response, $args) {
        return $response->withJson(["name" => "myaction2"]); 
     });
}

now when i call 'myaction' using ajax post i got success with this response "name" => "myaction"

but when i call 'myaction2' using ajax post i got success with same 'myaction' response "name" => "myaction" ,while i should got "name" => "myaction2"
any idea ?
Thanx ...


arbei
User
Posts: 9384

Post by arbei »

If you use Use route cache, as the docs says:
When you deploy new versions of your scripts (for example, after adding or deleting a table) to production, you must delete the generated file (<ProjectFolder>/<LogFolder>/cache/RouteCache.php) to ensure that the cache will be re-compiled.

Note that there are two route cache files, one for API, one for others, if you use Api_Action event, you should delete the <ProjectFolder>/api/<LogFolder>/cache/ApiRouteCache.php.


rembo
User
Posts: 227

Post by rembo »

Yep , Cleared Api log cache folder works fine now.
Thanx


Post Reply