post request using axios on Laravel 7

  laravel

i am trying to post request on server by axois but unfortunately page is refreshing on button click how can i resolve this issue please help me thanks.

html view

axois script

<script>
$(document).ready(function(){

  $("#prospects_form").submit(function(e) {
    let url = "{{route('home.store')}}";

    var name =$("#name").val();
    var email =$("#email").val();

      axios.post(url, {
      params:{
        name: 'name',
        email:'email'
      }
      }).then((res)=>{
         console.log(res);
      }).catch(function(err){
        console.log(err);
      });

  });
});

</script> 

Route

 Route::post('/home/store', '[email protected]')->name('home.store');

Source: Laravel

Leave a Reply