无法从服务器获取数据。 Axios,Vue.js
我的控制器:
@RestController
public class TestRestController {
@Autowired
private UserService userService;
@RequestMapping(value = "/test", method = RequestMethod.GET)
public ResponseEntity<List<User>> listAllUsers() {
List<User> users = userService.findAllUsers();
if (users.isEmpty()) {
return new ResponseEntity<List<User>>(HttpStatus.NOT_FOUND);
}
return new ResponseEntity<List<User>>(users, HttpStatus.OK);
}
}
我的vue.script
<template>
<p>Users {{users}}</p>
</template>
<script>
import {AXIOS} from './http-common'
export default {
name: 'TestAxios',
data() {
return {
users: []
}
},
methods: {
function() {
var params = new URLSearchParams();
AXIOS.get('/test', params)
.then(response => {
console.log(response.data);
this.users = response.data;
this.user.id = response.data;
})
.catch(error => {
console.log(error)
})
}
}
}
</script>
即使json也没有响应:((错误在哪里请帮助!
我需要在模板中指定什么?
但是不幸的是,数据没有显示在html页面上