3

I am using restangular to post a request to users/login

my laravel route is like so

Route::post('users/login', array('as' => 'login', function () {
    $input = Input::all();
    return Response::json($input);
}));

the data in the post header is formatted like so

{"input":["username":"un","password":"pw","remember":false]}

this dosn't work either

{"username":"un","password":"pw","remember":false}

this route is returning an empty array []. I am guessing my input is formatted incorrectly as from the laravel docs

Note: Some JavaScript libraries such as Backbone may send input to the application as JSON. You may access this data via Input::get like normal.

edit: it is working with this input ie. no quotes

{username:un,password:pw,remember:false]}

1 Answer 1

2

This is what you're looking for:

$input = Request::json()->all();

You can test it by returning the array directly from your route:

Route::post('users/login', array('as' => 'login', function ()
{
    $input = Request::json()->all();

    return $input;
}));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.