Reputation: 71
I'm attempting to refactor the "Node.JS PowerBI App Owns Data for Customers w/ Service Principal" code example (found HERE).
My objective is to import the data for the "config.json" from a table in my database and insert the "workspaceId" and "reportId" values from my database into the "getEmbedInfo()" function (inside the "embedConfigServices.js" file). Reason being, I want to use different configurations based on user attributes. I am using Auth0 to login users on the frontend, and I am sending the user metadata to the backend so that I can filter the database query by the user's company name.
I am able to console.log the config data, but I am having difficulty figuring out how to insert those results into the "getEmbedInfo()" function.
It feels like I'm making a simple syntax error somewhere, but I am stuck. Here's a sample of my code:
//----Code Snippet from "embedConfigServices.js" file ----//
async function getEmbedInfo() { try { const url = ; const set_config = async function () { let response = await axios.get(url); const config = response.data; console.log(config); }; set_config(); const embedParams = await getEmbedParamsForSingleReport( config.workspaceId, config.reportId ); return { accessToken: embedParams.embedToken.token, embedUrl: embedParams.reportsDetail, expiry: embedParams.embedToken.expiration, status: 200, }; } catch (err) { return { status: err.status, error: err.statusText, } }; } }
This is the error I am receiving on the frontend: "Cannot read property 'get' of undefined"
Any help would be much appreciated. Thanks in advance. Carlos
Upvotes: 0
Views: 580
Reputation: 1810
The error is because of fetching wrong URL. The problem is with the config for the Service Principal. We will need to provide reportId, workspaceId for the SPA and also make sure you added the service principal to workspace and followed all the steps from the below documentation for the service principal authentication.
References:
https://learn.microsoft.com/power-bi/developer/embedded/embed-service-principal
Upvotes: 0