'How to create a custom response base in Angular HTTP service?
I am returning a custom response from Spring Boot API as below:
public static ResponseEntity<Object> generateResponse(String message, HttpStatus status, Object responseObj) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("Message", message);
map.put("Status", status.value());
map.put("Output", responseObj);
return new ResponseEntity<Object>(map,status);
}
which it will return: message, status and the output. So now I am wondering how could I make a custom response in Angular to receive all these three attributes. How should I replace the "???" with? I should be customizing the response base right?
public Get(): Observable<Book>{
return this.http.get< ???<Book> >(this.baseUrl).pipe(map(response => response.Output))
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
