http://www.betterpixels.co.uk/projects/2015/05/09/mock-up-your-rest-api-with-json-server/
fetch('http://localhost:3000/tasks/')
.then(function(response) {
return response.json()
}).then(function(json) {
console.log('parsed json: ', json)
}).catch(function(ex) {
console.log('parsing failed: ', ex)
});
fetch('http://localhost:3000/tasks/', {
method: 'post',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"title": "Add a blogpost about Angular2",
"dueDate": "2015-05-23T18:25:43.511Z",
"done": false
})
}).then(function(response) {
return response.json()
}).then(function(json) {
console.log('parsed json: ', json)
}).catch(function(ex) {
console.log('parsing failed: ', ex)
});
RESTful & Rest parameters
http://www.ruanyifeng.com/blog/2011/09/restful.html
https://www.zhihu.com/question/28557115
Arrow_functions
https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Functions/Arrow_functions
基础语法
高级语法