1

How to redirect from Vue.js to laravel controller with post method without ajax so i can use var_dump or dd inside controller ?

//Vue.js
   axios.post('/add-hotel-listing', this.finish).then((response) => {

                });
//Laravel
   public function addHotelListing(Request $request){

        $input=$request->all();

       dd($input);

    }
Silvio Hanky
  • 51
  • 2
  • 5
  • not sure what (or why) you're trying to do. If it's for debug purposes, just use the dev tools' network panel to see the response, which will show your `var_dump` response – Daniel May 29 '18 at 16:31
  • I need to debug object in laravel controller because i have complex object and i need to use so many foreach and other function inside laravel to write in database...So i want to see whats going on when i use var_dump or dd...With axios i can't use var_dump he response in console log and that is all.... – Silvio Hanky May 29 '18 at 16:36
  • look at the image in this question https://stackoverflow.com/questions/44838290/rest-api-testing-how-to-get-response-using-google-chrome-developer-tools you will see preview and response tabs, if you select the request you are trying to debug, and look at the response (or preview) you will see your output. you do not need to use `console.log()` – Daniel May 29 '18 at 16:40
  • I know that but i want to debug inside laravel like this https://stackoverflow.com/questions/47126882/attributes-vs-original-in-laravel-when-dd i dont want to use console.log() its not so simple because i have so many objects and array inside one object – Silvio Hanky May 29 '18 at 16:44

2 Answers2

2

To redirect without ajax, you just have to use classic JavaScript:

window.location.href = "/new/window/location";
Nathan Strutz
  • 8,095
  • 1
  • 37
  • 48
  • Ok but how in that redirect to send some value because this is Route::post('/add-hotel-listing-property','ListingController@addHotelListingProperty'); post method in my laravel ? – Silvio Hanky May 29 '18 at 17:36
  • It's ugly, but... https://stackoverflow.com/questions/2367979/pass-post-data-with-window-location-href – Nathan Strutz May 29 '18 at 17:37
  • 1
    That's it thank you very much mate you save my day <3 I need to use this just to set up all in controller after that i can put in axios and all will work like water... – Silvio Hanky May 29 '18 at 17:46
0

First create a router instance:

var router = new VueRouter() ;

Then create your redirection with the router:

router.go('/');