init push
This commit is contained in:
20
backend/services/tiktok.js
Normal file
20
backend/services/tiktok.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import fetch from 'node-fetch';
|
||||
|
||||
export async function getTikTokData(url) {
|
||||
const oembedUrl = `https://www.tiktok.com/oembed?url=${encodeURIComponent(url)}`;
|
||||
const response = await fetch(oembedUrl);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`TikTok oEmbed Fehler: ${response.status}`);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
return {
|
||||
title: data.title || '',
|
||||
author: data.author_name || '',
|
||||
authorUrl: data.author_url || '',
|
||||
thumbnail: data.thumbnail_url || '',
|
||||
embedHtml: data.html || '',
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user