How to refresh/reload page after logout?

I would like to refresh my page/website after this code :

$w . onReady (() => { $w ( “#logoutButton” ). onClick ( logoutAndRedirect );}); function logoutAndRedirect ( event ) { Promise . all ( [ wixLocation . to ( “https://onlinesanawad.editorx.io/business” ), wixUsers . logout () ] );} //---------------------------------------------------------
Kindly help me. Thanks in advance : )

Currently there is no API to refresh a page. It has been requested and it is in the works, but it will take a while. In the mean time, the only working solution I found is a double redirect:

  1. do a wixLocation.to to a dummy page, e.g. “reload”
  2. on that dummy page, do another wixLocation.to back to the first page. It’s clumsy, but it’s your best bet.

Thanks, I thought for the same to navigate to a lightbox than connect buttons to another page like home.

Hi there :wave:t2: I have a similar solution to Giri’s.
I have a “logout” button, which is linked to a page called Logout.
A user clicks the button and is taken to the Logout page, where I run the code below to log them out and redirect them where I want them to go.

import wixLocation from 'wix-location';
import wixUsers from 'wix-users';

$w.onReady(function () {
    wixUsers.logout()
    setTimeout(() => {
        wixLocation.to("https://example.com/");
    }, 1500); // set in milliseconds
});

I have some messaging on the page saying “You are now logged out and will be redirected to our homepage”, etc, but that’s not wholly necessary.

Thanks a ton it works : )