这是我第一次安装和使用 VSCode,当我尝试安装Prettier扩展时,它让我在关闭它并显示此通知之前快速查看扩展页面(附截图):
无法打开“扩展:更漂亮 - 代码格式化程序”:发生未知错误。请查阅日志以获取更多详细信息..
它与所有其他扩展一起这样做。搜索了一个解决方案,但没有发现任何适用的内容。为什么会发生这种情况以及如何解决?
我是Nestjs、Typescript 和后端开发的新手。我正在开发一个简单的 Weather 应用程序,在那里我从Open Weather API获取天气数据。我正在使用内置的 NestHttpModule来包装 Axios,然后使用HttpService它向 Open weather 发出 GET 请求。该请求正在返回一个 Observable,这对我来说完全是新闻。如何从 中的 observable 中提取实际响应数据Injectable service并将其返回给Controller?
这是我的 weather.service.ts
import { Injectable, HttpService } from '@nestjs/common';
@Injectable()
export class AppService {
constructor(private httpService: HttpService) {}
getWeather() {
let obs = this.httpService.get('https://api.openweathermap.org/data/2.5/weather?q=cairo&appid=c9661625b3eb09eed099288fbfad560a');
console.log('just before subscribe');
obs.subscribe((x) => {
let {weather} = x.data;
console.log(weather);
})
console.log('After subscribe');
// TODO: Should extract and return response data f
// return;
} …Run Code Online (Sandbox Code Playgroud)