L
L
lemonlimelike2018-11-28 21:49:43
Laravel
lemonlimelike, 2018-11-28 21:49:43

How to make a get request to the server?

Hello. I want to make a dynamic sorting by records from the database and so that it is somehow displayed in the url'e. To do this, I call a function on the front. I use axios in the function:

function sort(param, type){
    axios.get('sort',{
      params:{
        type: type,
        param: param
      }
    }).then((response)=>{
      console.log(response)
    }).catch((error)=>{
      console.log(error.response)
    });
  }

Here is what my request looks like: 5bfee26327300141923042.png
And here is the root:
Route::get('sort?type={type}&param={param}','[email protected]');

And in the controller, I just return these parameters back.
But as you can see on the screenshot, this approach does not work, the request response is 404.
How to do it right?
It is desirable that the url'e should look like this: sort?type=films&param=datehow to achieve this?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question