cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to access user details in UI5 application in BAS hosted on BTP cloud foundry.

devansh795
Newcomer
0 Kudos
79

Hi All,
I am trying to get details of user who as logged in to the application which is hosted on BTP cloud foundry.
I am using BAS for development.
I have used this code for this:

_fetchUserInfo: function () {
        fetch("/user-api/userinfo")
          .then(response => {
            if (!response.ok) {
              throw new Error("Failed to fetch user info");
            }
            return response.json();
          })
          .then(userInfo => {
            console.log("Logged-in user info:", userInfo);
            MessageToast.show("Welcome, " + userInfo.user_name);
          })
          .catch(error => {
            console.error("Error fetching user info:", error);
          });
      }

I have added the user api in xs-app.json as well:

"routes":[
{
      "csrfProtection": false,
      "source": "^/user-api(.*)",
      "target": "$1",
      "service": "sap-approuter-userapi",
      "authenticationType": "xsuaa"
    } 
]

After deploying the application to BTP I am getting error 404 not found.

devansh795_0-1745927381841.png

Should I add this
this.getOwnerComponent().getManifestObject().resolveUri(sPath); in url

Please let me know how i can fix this issue.


 

Accepted Solutions (0)

Answers (0)