背景:后端springboot,前端鸿蒙JS
问题:鸿蒙JS端使用fetch调用后端方法,返回success,但是获取不到返回的数据。
后端:
/**
* 通过uid查询该用户的学习记录
* @param
* @return
*/
@RequestMapping("/getStudyLog/{uid}")
public String getStudyLog(@PathVariable("uid") Integer uid){
System.out.println("---------" +uid);
String data = studyLogService.listStudyLogByUid(uid).toString();
return data;
}
鸿蒙JS前端:
/*通过uid查看学习记录*/
listStudyLog(){
fetch.fetch({
url: 'http://cjhmouos9rcv.ngrok2.xiaomiqiu.cn/studyLog/getStudyLog/'+1,
method: 'GET',
header:{'Content-Type': 'application/json;charset=utf-8'},
success:function(response){
console.info("---------success");
console.info("-------data="+response.data);
},
fail: function(response){
console.info("-----------fail");
}
})
运行结果:
前端:
我尝试把后端的返回直接改成 return "Hellen"; 前端就能获取到并输出。
想问下各位这是为什么?谢谢!