title: Http failure response for 404 Not Found in ionic 5
body: <p>I am currently working on a logout module, however it gives me the following message.</p>
  
  <p><a href="https://i.stack.imgur.com/c30BH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/c30BH.png" alt="enter image description here"></a></p>
  
  <p>my file <code>logout.page.ts</code> is the following, In the logout method I call a service that brings my alerts to confirm the one that is closing the session</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import { Component, OnInit } from '@angular/core';
  import {AlertController} from "@ionic/angular";
  import {Router} from '@angular/router';
  import { UserService } from '../../services/user.service'
  import { AlertService} from '../../services/alert.service';
  
  @Component({
    selector: 'app-logout',
    templateUrl: './logout.page.html',
    styleUrls: ['./logout.page.scss'],
  })
  export class LogoutPage implements OnInit {
  
    constructor(public alertController: AlertController, 
      public router: Router, 
      public userService: UserService,
      public alertService: AlertService) { }
  
    ngOnInit() {
    }
  
  logout() {
    this.userService.logout().subscribe(
      data =&gt; {
        this.alertService.presentToast(data['message']);        
      },
      error =&gt; {
        console.log(error);
      },
      () =&gt; {
        this.router.navigate(['']);
      }
    );
  }
  
  
  
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>my file <code>user.service.ts</code> is the following in the logout method try to change the format where the application token is being brought, leave it in several ways until you reach this one, but when running the application again it throws at me that it cannot find the route that I am indicating</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import { Injectable } from '@angular/core';
  import {HttpClient, HttpHeaders } from "@angular/common/http";
  import {environment} from "../../environments/environment";
  import { EnvService } from './env.service';
  import { NativeStorage } from '@ionic-native/native-storage/ngx';
  import { tap } from 'rxjs/operators';
  
  
  @Injectable({
    providedIn: 'root'
  })
  export class UserService {
  
    isLoggedIn = false;
    token:any;
  
    constructor(private http: HttpClient,
      private storage: NativeStorage,
      private env: EnvService,) { }
  
    public getToken(username: string, password: string) {
      const url = environment.api + 'oauth/token';
      const params = {
        grant_type: 'password',
        client_id: environment.client_id,
        client_secret: environment.client_secret,
        'username': username,
        'password': password,
        scope: '*'
      };
      return this.http.post(url, params, {});
    }
  
    getPassport() {
      const header = new HttpHeaders({
        'Content_Type': 'application/json',
        'Authorization': 'Bearer ' + localStorage.getItem('token')
      });
    }
  
    logout() {
      const headers = new HttpHeaders({
        'Content_Type': 'application/json',
        'Authorization': 'Bearer ' + localStorage.getItem('token')
      });
      return this.http.get(this.env.API_URL + 'oauth/logout', { headers: headers })
      .pipe(
        tap(data =&gt; {
          this.storage.remove("token");
          this.isLoggedIn = false;
          delete this.token;
          return data;
        })
      )
    }
  
    
    getTokenUrl() {
      return this.storage.getItem('token').then(
        data =&gt; {
          this.token = data;
          if(this.token != null) {
            this.isLoggedIn=true;
          } else {
            this.isLoggedIn=false;
          }
        },
        error =&gt; {
          this.token = null;
          this.isLoggedIn=false;
        }
      );
    }
  
  
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>change my path from <code>oauth / logout</code> but the problem still persists, indicating that it cannot find that path</p>