Error: Unreachable code detected ionic 3 weather app

lcrimsonl

Ok, so I am following along the traversy media tutorial on ionic 3, and when i get to the part where you create a provider I get and error that says unreachable code detected in here:

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

and it also says on typescript

cannot find the name 'map' did you mean 'Map'?

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() );
 }

}
ketchupisred

The return statement in getWeather() is making the .map() unreachable. You should make the return statement the last statement in the function.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

unreachable code detected on for loop

Unreachable code detected in function

Make "Unreachable code detected" compilation warning instead of error in TypeScript?

How do I solve the "unreachable code detected" error in "if" statement?

for loop - "Unreachable code detected" - Test

Unreachable code detected in C# Controller

.NET C# Unreachable code detected

error TS7027: Unreachable code detected in Angular2 TypeScript Service class

Unreachable code compiler error

Code Unreachable Error in Code As Warnng

No "unreachable code detected"-warning in Visual Studio for new exception after return

Why isn't unreachable code detected when an if condition is a constant?

Unreachable code detected in simple method with only one return

CS0429 - Unreachable expression code detected with MSBuild 4, but not 14

C# Getting Unreachable Code Detected when using StreamWriter

Ionic 3 Android Studio detected

How to fix inxi: "Error: weather info downloaded but no data detected."?

No provider for App Error ,Ionic 3 in StackBlitz

Unreachable code compiling without error - How?

Dialogflow is giving error unreachable code after return

how to solve error :This code is unreachable - in pycharm

SQL Server gives error to unreachable code

Unreachable code, compilation error vicious circle

"glibc detected" error on c code

Ionic 3 Unauthorized modifications to this JAR entry will not be detected

Robo 3T Error : Network is unreachable

Google Plus login gives error code 10 in signed ionic app

Return error code after first detected error

Ionic 3 PWA app breakpoints and source code in the browser are messed up

TOP Ranking

HotTag

Archive