Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

MichaelDaly's avatar

Redirect after spark post

I am building an app on top of Spark and have built a custom component.

I want to redirect to an index page after I save a new item to the database using the following code:

Spark.post('/events/add', this.form);

I have tried to use the following line, however, this doesn't seem to exist in the current Spark instance:

Spark.get('/events');

It would be great if someone could point me in the right direction of how to resolve this issue. I have looked at the official spark documentation and I was not able to find any information related to this.

Thanks in advance.

0 likes
2 replies
MichaelDaly's avatar

To give a quick update:

I have used this line of code:

Vue.http.get('/events');

I opened the network tab in the browser and I can see the response has been returned successfully and contains all the html from the 'events' view, however, the current page does not update.

I want to do a full redirect to the view rather than return the view in the response.

I feel like I am missing out a crucial step but I cannot seem to figure it out.

I would really appreciate help with this.

Thanks again.

MichaelDaly's avatar

I have just gone with the following:

window.location = '/events';

Although this doesn't feel right, I have to crack on with the rest of the app so I will come back to this and post an update so it can help others in the future.

1 like

Please or to participate in this conversation.