Added backend Youtube feed support
This commit is contained in:
32
Modules/webSubManager.js
Normal file
32
Modules/webSubManager.js
Normal file
@@ -0,0 +1,32 @@
|
||||
import { error } from './logManager';
|
||||
|
||||
|
||||
export async function subbWebSub(callback, topic, hub) {
|
||||
const options = {
|
||||
method: 'POST',
|
||||
mode: 'cors',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ 'hub.mode': 'subscribe', 'hub.topic': topic, 'hub.callback': callback, 'hub.verify': 'sync' }),
|
||||
};
|
||||
|
||||
return await fetch(hub, options)
|
||||
.then(res => {
|
||||
res.status === 204 ? true : false;
|
||||
})
|
||||
.catch(err => error(err));
|
||||
}
|
||||
|
||||
export async function unsubWebSub(callback, topic, hub) {
|
||||
const options = {
|
||||
method: 'POST',
|
||||
mode: 'cors',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ 'hub.mode': 'unsubscribe', 'hub.topic': topic, 'hub.callback': callback, 'hub.verify': 'sync' }),
|
||||
};
|
||||
|
||||
return await fetch(hub, options)
|
||||
.then(res => {
|
||||
res.status === 204 ? true : false;
|
||||
})
|
||||
.catch(err => error(err));
|
||||
}
|
||||
Reference in New Issue
Block a user