I'm encountering an issue with receiving a response message from a Spring RESTful web service to an AngularJS client. When using ResponseEntity<String>
to send a response, everything works fine when only returning a status code. However, AngularJS throws an error (Unexpected token R
) when I include a response message in the body.
What could be causing this problem?
return new ResponseEntity<String>(HttpStatus.OK);
But when trying to return a message along with the status code:
return new ResponseEntity<String>("Report was updated successfully", HttpStatus.OK);
Snippet of AngularJS code:
$http.get(url, header)
.success(function(data, status, headers, config) {
// handle success
}).error(function(resp, status) {
// handle error
});
The current response is blank.