2 weeks ago - last edited 2 weeks ago
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.
Should I add this
this.getOwnerComponent().getManifestObject().resolveUri(sPath); in url
Please let me know how i can fix this issue.
Request clarification before answering.
User | Count |
---|---|
73 | |
21 | |
9 | |
8 | |
7 | |
6 | |
5 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.