Home Support Themes TaskHive Get Logged in User data through an API.

Get Logged in User data through an API.

  • Author
  • m.ali.rashid

    Hey Team
    I have created a new page and integrated it with ReactJS. I want to call a REST API endpoint using fetch() where I can get the currently logged-in user.
    This is my code so far.

    async function loadUserData() {
          const response = await fetch( "http://beyondsport.co/wp-json/hivepress/" );
          if (!response.ok) { return; }
          const data= await response.json();

    As You can see, I need an API end-point to get logged-in user data.

    ihor developer


    Please try using the official WordPress REST API for fetching users https://developer.wordpress.org/rest-api/reference/users/


    Thanks. But I need to know which user is logged in. Similar to wp_get_current_user(). But using RestAPI.


    Thanks @ihor
    This is the rest-api end-point I’m using

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.