Introducing ReUI:Open-source UI components and apps built with React, Next.js and Tailwind CSS
Browse ReUI

How to provide latest valid access token to the data table api call in Metronic 9


HI,

Background:
I am using Remote data source for DataTable in Metronic 9 html + Nextjs, it provides requestHeaders option, which i am using to pass Authorization header with Bearer access token in it to make the server side call pass through the auth.

Problem:
In regular app when api call is failed due to expired access token, i fetch new access token and redo the api call,

How can i provide new access token in the Remote Data Table requestHeaders option incase my access token gets expired.

Although i provided the app context value in the requestHeaders option, but it always uses the data table initialization time context value, instead of the latest value available in the app context.


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (5)


Referee decisions, including penalties, red cards, and VAR reviews, have a significant impact on live betting https://linebet-arab.com/ma-fr/ markets in the Arab world. Bettors often adjust their wagers in response to key referee calls, leading to rapid changes in odds. Some betting platforms offer specialized markets on VAR decisions, further increasing engagement. The unpredictability of refereeing decisions adds another layer of excitement to live betting.



Hi,

You can try to pass the token via the request header according to your app requirements.


requestHeaders: () => ({
Authorization: `Bearer ${getLatestAccessToken()}`
})


Regards,
Sean



Hi,

Yes when I pass this in the requestHeaders option, the data table is initialized with this option and data is loaded first time,

but lets say access token is expired, and i go to another page or search some thing then how to pass new access token to the data table, as it keep using the old access token given at data initialization time instead of calling the getLatestAccessToken() function again to get the new access token.

As getLatestAccessToken() is called at table initialization time, not afterwards.



Hi,

Thank you for reaching out to us.

Could you please clarify which API you are using?

In most of our APIs, the access token is retrieved during the login process then you can use this token to set the Authorization header.

Regards,
Lauris Stepanovs,
Keenthemes Support Team



Jika Anda mencari permainan sederhana namun mengasyikkan, Plinko Game adalah pilihan yang tepat! Dengan mekanisme https://plinko-game.id/ permainan yang mudah dipahami, Anda hanya perlu menjatuhkan bola dan menunggu keberuntungan menentukan kemenangan Anda. Grafik yang menarik, pembayaran besar, dan gameplay yang adiktif membuatnya menjadi favorit banyak pemain.


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(