0

I have a simple Vue app in which I am sending POST request with options (table filtering variables) to the back-end. I want to be able to destructure the object and debug it in my TestController in Laravel 8, so I want to send the options to web.php via URL, not to api.php. Since options is an object, I cannot just drop it in the URL.

Ultimately I want to be able to preview my Laravel respond in browser, so I know it returns correct data from server.

So how can I achieve this?

2 Answers 2

1

in Vue FormComponent <form @submit="formSubmit"> and script

function formSubmit(e) {
    e.preventDefault();
    let currentObj = this;
    axios.post('/formSubmit', {
        name: this.name,
        description: this.description
    }).then(function(response) {
        currentObj.output = response.data;
        console.log(currentObj);
    }).catch(function(error) {
        currentObj.output = error;
    });
}
Sign up to request clarification or add additional context in comments.

1 Comment

this is regular api call, will work. this will return data into my app; I am actually trying to just go to by browser, open new page, type in URL and inspect data coming from the server.
0

Firstable, create POST route for your request. Then just make POST request to this route url and put your POST params (your object) to request body. You can use Axios as example

let filterOptions = {...};
axios.post(url, filterOptions).then().catch();

UPD And response for your request you can see in browser developer console on network tab

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.