ui: create new feed

This commit is contained in:
Nazar Kanaev
2020-07-01 17:22:06 +01:00
parent 14781476e0
commit 866d59fe86
3 changed files with 63 additions and 19 deletions

View File

@@ -0,0 +1,25 @@
"use strict";
(function() {
var api = function(method, endpoint, data) {
var promise = fetch(endpoint, {
method: method,
headers: {'content-type': 'application/json'},
body: JSON.stringify(data),
})
return promise.then(function(res) {
if (res.ok) return res.json()
})
}
window.api = {
feeds: {
list: function() {
return api('get', '/api/feeds')
},
create: function(data) {
return api('post', '/api/feeds', data)
},
}
}
})()