首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >错误:无法到达的代码检测到离子3天气应用程序

错误:无法到达的代码检测到离子3天气应用程序
EN

Stack Overflow用户
提问于 2018-11-13 20:36:55
回答 1查看 173关注 0票数 0

好的,接下来是关于离子3的遍历媒体教程,当我进入创建提供者的部分时,我会得到和错误,在这里检测到无法到达的代码:

.map((res: Response) => res.json() );

它还写在打字稿上

找不到“地图”这个名字你的意思是“地图”吗?

代码语言:javascript
复制
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import 'rxjs/add/operator/map';

@Injectable()
export class WeatherProvider {
  apiKey = "89cca14f4ffcd27d602ad5e587f8e17f";
  url;

 constructor(public http: HttpClient) {
   console.log('Hello WeatherProvider Provider');
   this.url = "api.openweathermap.org/data/2.5/weather?q=";
 }



 getWeather(city, country){
 return this.http.get(this.url+city+','+country);
   .map((res: Response) => res.json() );
 }

}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-11-13 21:13:15

getWeather()中的返回语句使.map()无法访问。您应该将return语句作为函数中的最后一个语句。

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

https://stackoverflow.com/questions/53289111

复制
相关文章

相似问题

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