2

I have fetch api call from Vue js code which sends form-data to laravel backend I am posting request. Please suggest how to parse this using laravel request?

POST /acapp/public/api/createmember HTTP/1.1
Accept:          */*
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9,mr-IN;q=0.8,mr;q=0.7,ur-PK;q=0.6,ur;q=0.5,hi-IN;q=0.4,hi;q=0.3
Cache-Control:   no-cache
Connection:      keep-alive
Content-Length:  142
Content-Type:    application/json
Host:            localhost
Mimetype:        multipart/form-data
Origin:          chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop
Postman-Token:   cd1ca586-560b-fdf7-3fd6-afe2f457d676
User-Agent:      Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36

------WebKitFormBoundaryoMWbAbNZyySY3vCB
Content-Disposition: form-data; name="dob"

45345345
------WebKitFormBoundaryoMWbAbNZyySY3vCB--

2
  • Laravel should be parsing it automatically. Commented Nov 1, 2018 at 11:28
  • I tried doing $request->dob; getting no value. Commented Nov 1, 2018 at 11:31

1 Answer 1

1

You don't need to parse the request. The HTTP-Request Stack of Laravel will do it automatically and call your action you defined for that url.

https://laravel.com/docs/5.7/requests

Here is a good example how to get informations from your request. So you don't have to think about that. In the documentation you can find a part how to write VUE components.

https://laravel.com/docs/5.7/frontend

i think that could help you.

Sign up to request clarification or add additional context in comments.

2 Comments

According to you, $request->dob should give me value for dob in above request. But, I am getting empty response.
Perhaps the CSRF protection is a problem. When you don't have the security key in your form then it's possible that you don't get a proper form. laravel.com/docs/5.7/csrf And you should use the form method to validate it. What is with $field = Input::get('bob');

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.