我正在尝试将 Looker Embedded Client SDK 与 Angular 集成,因此已安装 @looker/SDK 并按照官方 npm 页面上提供的指导方针配置设置,以便 @looker/sdk 访问 API。
但是当我尝试访问一些方法和类时,角度应用程序开始失败。外观
错误:
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" />
和配置:
// 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')
}
}