Http 我在chrome开发者工具中看到了响应主体,但无法在前端中检索它

Http 我在chrome开发者工具中看到了响应主体,但无法在前端中检索它,http,grails,response,Http,Grails,Response,我目前正在一个项目中工作,需要从grails后端向ReactJs前端发送响应。我能够使用“response”从grails控制器发送响应,但无法在ReactJs端提取响应体。我尝试签入以下内容,发现空值或未定义 response.content,response.body 我在ChromeWebDeveloperTools的“网络”选项卡中看到了我从grails发回的响应。但无法找出响应对象的哪个字段实际拥有它。任何有关这方面的帮助都将不胜感激 我的http请求 post: function(u

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

response.content,response.body

我在ChromeWebDeveloperTools的“网络”选项卡中看到了我从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"

response您是否尝试过内容类型:“application/json”

您是否尝试过内容类型:“application/json”

尝试
render“出现错误”

或者,如果需要呈现JSON:

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

要了解grails控制器和视图是如何工作的,请阅读简单的示例。

尝试
渲染“出现错误”

或者,如果需要呈现JSON:

render [someKey: 'there is an error'] as JSON
要了解grails控制器和视图是如何工作的,请阅读简单的示例