POST – VsCode plugin Rest Client

I’m working on a simple laravel api but the post method on Rest client only returns a redirection.
This is my RegisterController,

public function store(Request $request)
{
    $this->validate($request, [
        'name' => 'required|max:255',
        'username' => 'required|max:255',
        'email' => 'required|email|max:255',
        'password' => 'required|confirmed',
    ]);

    $success = User::create([
        'name' => $request->name,
        'username' => $request->username,
        'email' => $request->email,
        'password' => Hash::make($request->password),
    ]);

    return [
        'success' => $success
    ];
}

and this is the model,

protected $fillable = [
    'name',
    'username',
    'email',
    'password',
];

and here is the rest client post method, I put the Route on api.php,

POST http://127.0.0.1:8000/api/register
Content-Type: application/json

{

"name": "name 2",
"username": "username 2",
"email": "[email protected]",
"password": "name2pass",

}

Then the result will only return a redirection,

HTTP/1.1 302 Found
Host: 127.0.0.1:8000
Date: Thu, 25 Feb 2021 18:42:40 GMT, Thu, 25 Feb 2021 18:42:40 GMT
Connection: close
X-Powered-By: PHP/7.3.27
Cache-Control: no-cache, private
Location: http://127.0.0.1:8000
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 58
Content-Type: text/html; charset=UTF-8
Access-Control-Allow-Origin: *

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
    <meta http-equiv="refresh" content="0;url='http://127.0.0.1:8000'" />

    <title>Redirecting to http://127.0.0.1:8000</title>
</head>
<body>
    Redirecting to <a href="http://127.0.0.1:8000">http://127.0.0.1:8000</a>.
</body>
</html>

Source: Ask PHP

LEAVE A COMMENT