when i hit api with post method the result this: please tell me what is problem here
[]
[]
This is CSRF token issue. If you want to except CSRF token on particular route then you can go on /app/Http/Middleware/VerifyCsrfToken.php
Write your route name in $except array.
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
class VerifyCsrfToken extends BaseVerifier
{
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array
*/
protected $except = [
'login', 'webservice'
];
}
that is the CSRF token issue. if you want to run api in post method then you want to except CSRF token for api.
Remove csrf token:- goto /app/Http/Middleware/VerifyCsrfToken.php and write your route name in $except array.
like this:
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
class VerifyCsrfToken extends BaseVerifier
{
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array
*/
protected $except = [
'login', 'api'
];
}
that will be work definitely.. :)
this also work
app > Http > Kernel.php
and comment the same line as I did:
/**
* The application's global HTTP middleware stack.
*
* @var array
*/
protected $middleware = [
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
// \App\Http\Middleware\VerifyCsrfToken::class,
];