jeudi 2 novembre 2017

Laravel with Angular Request Issue

I've this on my Laravel controller:

    public function store(CreateRequest $request)
    {
        // Create a random password
        $password    = str_random(6);
        $encPassword = bcrypt($password);

        // Add password to the request to save it on createOrUpdate method
        $request->request->add(['password' => $encPassword]);

        dd($request->all());

    }

If I made a request from postman I get the right response, like:

array:3 [
  "email" => "darthvader4@app.com"
  "roles" => "1"
  "password" => "$2y$10$qdnk6TX09pxd35v5mvTtfOEChV3ADbV0h3Q2WSc8g4R7F2UbuoENu"
]

but when I try to make the request from the angular application, this is the response I get:

array:2 [
  "email" => "mcarvalho@example.com",
  "roles" => "1"
]

Anyone have an ideia why the $request->request->add['password' => $encPassword]); is not working on angular app?

Headers for postman

Accept application/json

Content-Type application/json

Headers from Angular application

Accept:application/json, text/plain, /

Content-Type:application/json

PS

If I do this dd($request->request->all()); it works for both Angular and Postman, but doesn't make any sense to me why works on one and on the other don't.

Thank you all!



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2yoEGhT
via IFTTT

Aucun commentaire:

Enregistrer un commentaire