I am attempting to create a TikTok video downloader using your library. The route.params.video_url is set to https://www.tiktok.com/@devslopes/video/7276699914241985835?is_from_webapp=1&sender_device=pc.
The issue I'm encountering only occurs when I execute the function in a React Native app. It does not occur when I run a script like node index.js. Below are the code examples for both scenarios:
Node.js Script:
const TiktokDL = require("@tobyg74/tiktok-api-dl");
TiktokDL("https://www.tiktok.com/@devslopes/video/7276699914241985835?is_from_webapp=1&sender_device=pc").then((result) => {
console.log(result);
});
React Native Code:
import { Dimensions, View, Image } from 'react-native';
import { ActivityIndicator, Text } from 'react-native-paper';
import { useEffect, useState } from 'react';
import { DLResult } from '@tobyg74/tiktok-api-dl/lib/types';
import { TiktokDL } from '@tobyg74/tiktok-api-dl';
export default function ({ route, navigation }: any) {
const [isLoading, setIsLoading] = useState<boolean>(true);
const [data, setData] = useState<DLResult | null | void>(null);
useEffect(() => {
TiktokDL(route.params.video_url).then((result) => {
setIsLoading(false);
setData(result);
console.log(result);
});
}, []);
return (
<View style={{
height: Dimensions.get("window").height,
backgroundColor: "#15131A"
}}>
<View style={{
marginTop: 30,
padding: 20
}}>
{isLoading ? <ActivityIndicator size={"large"} /> : null}
{!isLoading && data && data.result != null ? (
<>
<View>
<View style={{
display: "flex",
flexDirection: "row",
justifyContent: "space-between",
alignItems: "center"
}}>
<View>
<Image
source={{
uri: data.result.cover?.toString()
}}
/>
</View>
<Text style={{ color: "#fff" }}>{data.result.description}</Text>
</View>
</View>
</>
) : null}
{data?.status == "error" && (
<Text style={{ color: "red", fontSize: 16 }}>{data?.message}</Text>
)}
</View>
</View>
);
}
The issue I'm facing is titled "Cannot read property 'responseUrl' of undefined."