Issue with API Fields updating instantly within Nav Bar App | Community
Skip to main content

Issue with API Fields updating instantly within Nav Bar App

  • July 13, 2022
  • 6 replies
  • 0 views

Gaby11

I'm using client.request() to update a Users Suspension status however it does not update until the iframe is exited or the page is completely refreshed. Is there a solution to updating this instantly so it can reflect within the app?

Here is my current code:

function suspendUser(userID){
    const options = {
  url: '/api/v2/users/'+ userID,
  type: 'PUT',
  data: JSON.stringify({
    user: {
      suspended: true
    }
  }),
  contentType: 'application/json'
};

client.request(options).then(
  (res) => {
    console.log(`Suspended user ${res.user.id}`);
    client.invoke('notify',`Suspended user ${res.user.name}`, 'notice');
    reloadUsers();
  },
  (res) => {
    console.log(`Error ${res.status}`);
    client.invoke('notify',`Error ${res.status}`, 'notice')
  }
);
}

6 replies

Eric27
  • July 13, 2022
Hey Gaby,

Are you saying that the user suspension event doesn't happen until the app refreshes or just the UI?

Thanks! 

Gaby11
  • Author
  • July 14, 2022

@eric27 Yes, the user suspension event doesn't happen until the app refreshes. Even if I use location.reload(); it doesn't work until the page refreshes completely. 


Eric27
  • July 14, 2022
Hey Gaby,

What do you have kicking off that function? I haven't been able to replicate your issue. Here is a small example application that is functioning as expected. Hopefully this can point you in the right direction.

Thanks,

Eric

Gaby11
  • Author
  • July 14, 2022

@eric27 I tried using this and I am still getting the same issue. As I do get a success popup notification saying the user was suspended, it doesn't update the API instantly, it updates after the app is refreshed.


Eric27
  • July 14, 2022
That's quite odd, mind if I move this into a ticket so I can assume into your account and take a look? 

Gaby11
  • Author
  • July 20, 2022

@eric27 I don't need to suspend users anymore and tried it with updating the User's custom roles and that updates instantly. There must be something with the Suspension field that delays in updating but luckily I don't need that right now. Thank you so much for your help again!