My Environments:
- Shop RestController : Spring Boot
- on localhost laptopn ubuntu 18:04
- ShopService: Angular HttpClient
- on localhost desktop pc windows 10
Problem:
My get request via HttpClient got the response null. But if I use postman or on browser, I got my expected response body.
Angular Code:
const BASE_URL = 'http://pc01:8081/shopsystem/shops';
const SHOP_NAME = 'Muster Shop';
@Injectable({
providedIn: 'root'
})
export class ShopService {
shop$: Shop;
address$: Address;
owner$: Owner;
//header = new HttpHeaders({ 'Content-Type': 'application/json' });
constructor(private http: HttpClient) { }
public getShop(): Observable<Shop>{
return this.http.get<Shop>(BASE_URL + '/' + SHOP_NAME);
}
Response-Header:
Response:
Request on postman:
Spring Boot controller:
I have already tried with Observable with any and HttpHeaders with application/json but same response.
Another thing: If my Spring Boot controller returns a List then I got the response body with contents.
Question:
Why I got a null or empty body in my HttpClient request?
How can I solve this?
Thank you





muster shoptomusterShopand see if you are still getting the null