[mirotalksfu] - update dep, API snippets

هذا الالتزام موجود في:
Miroslav Pejic
2023-07-26 15:15:01 +02:00
الأصل 7acd17680e
التزام b09dcff278

عرض الملف

@@ -1,13 +1,15 @@
'use strict';
const fetch = require('node-fetch');
async function getJoin() {
try {
// Use dynamic import with await
const { default: fetch } = await import('node-fetch');
const API_KEY = 'mirotalksfu_default_secret';
const MIROTALK_URL = 'https://sfu.mirotalk.com/api/v1/join';
// const MIROTALK_URL = 'http://localhost:3010/api/v1/join';
function getResponse() {
return fetch(MIROTALK_URL, {
const response = await fetch(MIROTALK_URL, {
method: 'POST',
headers: {
authorization: API_KEY,
@@ -23,10 +25,15 @@ function getResponse() {
notify: true,
}),
});
const data = await response.json();
if (data.error) {
console.log('Error:', data.error);
} else {
console.log('join:', data.join);
}
} catch (error) {
console.error('Error fetching data:', error);
}
}
getResponse().then(async (res) => {
console.log('Status code:', res.status);
const data = await res.json();
console.log('join:', data.join);
});
getJoin();