My current task involves integrating the Looker Embedded Client SDK with Angular. I have installed @looker/SDK and configured the settings as per the guidelines provided on the official npm page for @looker/sdk to access APIs.
However, upon attempting to access certain methods and classes, the Angular application encountered failures. The specific error message is:
ERROR in node_modules/@looker/sdk-rtl/lib/oauthSession.d.ts:1:23 - error TS2688: Cannot find type definition file for 'request'.
1 /// <reference types="request" />
Here is the configuration information:
// package.json
{
//package.json
"dependencies": {
"@angular/core": "~10.2.3",
"@looker/sdk": "^7.20.3",
// few other libs
},
"devDependencies": {
// few other libs
"@angular/cli": "~10.2.0",
"typescript": "~4.0.5"
},
//tsconfig.json
"compilerOptions": {
// few other settings
"module": "es2020",
"target": "es5",
"lib": [
"es2020",
"dom"
],
/ /And in component file:
import { LookerNodeSDK } from '@looker/sdk/lib/node'
@Component({
selector: 'rs-reports',
templateUrl: './reports.component.html',
providers: [ReportsService]
})
export class ReportsComponent implements OnInit {
constructor() {
}
ngOnInit() {
this.getLookerConfig()
.then(response => {
console.log(response, 'Success')
}).catch(error => {
console.log(error, 'Error')
});
}
async getLookerConfig() {
// create a Node SDK object for API 3.1
const sdk = LookerNodeSDK.init31();
// retrieve your user account to verify correct credentials
const me = await sdk.ok(sdk.me(
"id, first_name, last_name, display_name, email, personal_space_id, home_space_id, group_ids, role_ids"))
console.log({me})
// make any other calls to the Looker SDK
const dashboards = await sdk.ok(
sdk.search_dashboards({title: 'My SDK dashboard'})
)
if (dashboards.length === 0) {
console.log('Dashboard not found')
}
await sdk.authSession.logout()
if (!sdk.authSession.isAuthenticated()) {
console.log('Logout successful')
}
}