handle errors
This commit is contained in:
parent
fc860d5cc0
commit
e683e6fc62
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@tobyg74/tiktok-api-dl",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1-fix",
|
||||
"description": "Scrapper for download Video, Image, Music from Tiktok",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
||||
@ -11,14 +11,18 @@ const TiktokDL = (url) => {
|
||||
})
|
||||
.then(({ request }) => {
|
||||
const { responseUrl } = request.res;
|
||||
const ID = responseUrl.match(/\d{17,21}/g)[0];
|
||||
let ID = responseUrl.match(/\d{17,21}/g)
|
||||
if (ID === null) return reject({
|
||||
status: "error",
|
||||
message: "Failed to fetch tiktok url. Make sure your tiktok url is correct!",
|
||||
});
|
||||
ID = ID[0]
|
||||
Axios(_tiktokapi(ID), {
|
||||
method: "GET",
|
||||
})
|
||||
.then(({ data }) => {
|
||||
const content = data.aweme_list.filter((v) => v.aweme_id === ID)[0];
|
||||
if (content.aweme_id !== ID)
|
||||
return resolve({
|
||||
if (!content) return resolve({
|
||||
status: "error",
|
||||
message: "Failed to find tiktok data. Make sure your tiktok url is correct!",
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user