Я новичок в reactjs: у меня есть Springboot с одним сервисом, который возвращает ResponseEntity, как это:
@RequestMapping(value = "/startTest")
public ResponseEntity<String> runTest {
String response;
if (this.values>0){
response=String.format("Test Failed: %s", summary.getFailures().get(0).getException().getMessage());
}
else{
response="Test Successfull!";
}
return ResponseEntity.status(HttpStatus.OK).body(response);
В ответ у меня есть эта функция для тела чтения:
var url = "http://127.22.22.12:8090/startTest";
await fetch(url)
.then(function(response){return response.json();})
.then(function(data){const items=data;
console.log(items)
})
но у меня есть эта ошибка в консоли:
Uncaught (in promise) SyntaxError: Unexpected token T in JSON at position 0
, если написать console.log (response.text ()), я смотрю ОБЪЕКТ Promise, но как получить ОБЪЯВЛЕНИЕ в виде текста?
С уважением