ERROR HttpErrorResponse {headers: HttpHeaders, status: 401, statusText: “OK”, url: “http://localhost:8080/hello”, ok: false, …}

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


ERROR HttpErrorResponse {headers: HttpHeaders, status: 401, statusText: “OK”, url: “http://localhost:8080/hello”, ok: false, …}



I alwaaays get this error when trying to implement simple web service that display just a msg (angular5 + spring boot)
the error shown is in this img



this is my simple code:
controller.java:


@GetMapping("/hello")
public String sayhello(){ return "{"message": "Hello, world!"}";}
}



hello.component.ts:


import { Component, OnInit } from '@angular/core';
import { HttpClient, HttpErrorResponse, HttpParams } from '@angular/common/http';
import { Observable } from 'rxjs/Rx';
import { Adresse } from '../shared/adresse';
@Component({ selector: 'app-forgot', templateUrl: './forgot.component.html',
styleUrls: ['./forgot.component.css'] })
export class ForgotComponent implements OnInit {
message: string;
ip: string = Adresse.ip;
constructor(private http: HttpClient) { }
ngOnInit(): void {
this.http.get(this.ip+'/hello').subscribe(data=>
{console.log('DATA',data);
this.message= data['message'];}) }

}





1st: Dont post images of errors/ stacktraces. Copy them from your console into here. 2nd: Can you post your spring-security config please?
– mrkernelpanic
1 min ago









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Visual Studio Code: How to configure includePath for better IntelliSense results

Spring cloud config client Could not locate PropertySource

Makefile test if variable is not empty