我在 chrome 开发者工具中看到响应正文,但无法在前端检索它

I see the response body in chrome developer tools, but unable to retrieve it inside Front End

我目前在一个项目中工作,我需要将响应从 grails 后端发送到 ReactJs 前端。我能够使用 "response" 从 grails 控制器发送响应,但无法在 ReactJs 端提取响应主体。我尝试检查以下内容,发现空值或未定义。

response.content, response.body

我在 chrome 网络开发人员工具 "Network" 选项卡中看到我从 grails 发回的响应。但无法找出响应对象的哪个字段实际拥有它。对此的任何帮助将不胜感激。

我的 http 请求。

post: function(url, item) {

    return fetch(baseUrl + url, {
        headers: {
            'Accept': 'text/plain',
            'Content-Type': 'text/plain'
        },
        method: 'post',
        body: item
    }).then(function(response) {

        alert(response);
        return response ;
    });

},

圣杯

    response << "there is an error"

你试过内容类型吗:'application/json'

尝试render 'there is an error'
或者如果你需要渲染 JSON:

render [someKey: 'there is an error'] as JSON

要了解 grails 控制器和视图的工作原理,请阅读 this 简单示例。