首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >导入后未定义Airtable

导入后未定义Airtable
EN

Stack Overflow用户
提问于 2020-04-30 03:03:56
回答 2查看 517关注 0票数 0

我被赋予了这个任务,用NodeJS对从AirTable应用程序接口获得的数据执行一些操作。我使用的是AirTableJS节点库和DefinitelyTyped airtable定义(我使用的是NestJS)。

因此,我自然会执行以下操作来导入所需的包。

代码语言:javascript
运行
复制
yarn add airtable @types/airtable

然后,在与AirTable应用编程接口交互的存储库中,我有以下内容。

代码语言:javascript
运行
复制
import { User } from "../entities/user";
import { ConfigService } from "@nestjs/config";
import { Inject, Injectable } from "@nestjs/common";
import { LogService } from "src/log/services/log/log.service";
import { Base } from "airtable";


@Injectable()
export class UsersRepository {
    private readonly apiKey: string;
    private readonly baseId: string;

    constructor(@Inject(ConfigService) private readonly config: ConfigService, @Inject(LogService) private readonly log: LogService) {
        this.apiKey = this.config.get<string>('airtable.apiKey');
        this.baseId = this.config.get<string>('airtable.baseId');
    }

    async getUnmatchedUsers(): Promise<User[]> {

        const base: Base = new Airtable({apiKey: this.apiKey}).base(this.baseId);
        // other code here
     }
  }

但是,在运行它时,我得到了以下与存储库函数相关的错误:

代码语言:javascript
运行
复制
ReferenceError: Airtable is not defined

我是不是遗漏了什么,或者我没有正确导入Airtable包?

谢谢。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-04-30 03:52:23

未定义它,因为您尚未导入Airtable

这可能看起来像这样:

代码语言:javascript
运行
复制
import Airtable, { Base } from "airtable";
票数 1
EN

Stack Overflow用户

回答已采纳

发布于 2020-04-30 03:52:23

您没有从任何地方导入Airtable类,所以Node和Tyepscript根本不知道它是什么。最接近的是从airtable包导入的Base类型。由于他们的文档不是公开的,所以很难说如何修复它。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61509670

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档