mirror of
https://github.com/nkanaev/yarr.git
synced 2025-09-14 10:20:06 +00:00
ui: create new feed
This commit is contained in:
25
template/static/javascripts/api.js
Normal file
25
template/static/javascripts/api.js
Normal 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)
|
||||
},
|
||||
}
|
||||
}
|
||||
})()
|
Reference in New Issue
Block a user