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)
});
json-server & mock-data
https://gist.github.com/xgqfrms-GitHub/ddcbbac745c559d23da5e0a39b72220c
async function & async callback js & ES7
https://gist.github.com/xgqfrms-GitHub/0b568d347fdf84fb07119491610efc92
faker.js
fake data
https://github.com/ufo-github/faker.js
https://gist.github.com/xgqfrms-GitHub/cb8459af5e7db7af107a25615f738ab5