我希望下面的代码能够从我设置的简单API中获取JSON数据。export class FaqFakeDb public static data = fetch('https://#######.co.uk/api/faq/');
} 这是一个常见问题页面,它的目的是从API中提取数据。我刚开始使用typescript和Angular,所以如果我犯了一个简单的错误,请原谅。
我使用的是Angular和TypeScript。在API调用的情况下,我使用了try catch结构来处理错误。如果try块中出现任何错误,那么它根本不会去catch块。应用程序仅在那里终止。以下是示例代码片段,
this.api.getAPI(Id).subscribe( // this.api is my api service and getAPI is present(error: Htt