szdc / tiktok-api

Unofficial API wrapper for TikTok
MIT License
1.27k stars 279 forks source link

Unexpected token { when running #108

Closed kicks66 closed 3 years ago

kicks66 commented 5 years ago

I'm using the default setup mention in the docs:

import TikTokAPI, { getRequestParams } from 'tiktok-api';

// Required - a method that signs the URL with anti-spam parameters
// You must provide an implementation yourself to successfully make
// most requests with this library.
const signURL = async (url, ts, deviceId) => {
  const as = 'anti-spam parameter 1';
  const cp = 'anti-spam parameter 2'
  const mas = 'anti-spam parameter 3';
  return `${url}&as=${as}&cp=${cp}&mas=${mas}`;
}

// Required - device parameters
// You need to source these using a man-in-the-middle proxy such as mitmproxy,
// CharlesProxy or PacketCapture (Android)
const params = getRequestParams({
  device_id: '<device_id>',
  fp: '<device_fingerprint>',
  iid: '<install_id>',
  openudid: '<device_open_udid>',
});

const api = new TikTokAPI(params, { signURL });

With necessary parameters in. However I am getting the following error:

import TikTokAPI, { getRequestParams } from 'tiktok-api';
       ^^^^^^^^^

SyntaxError: Unexpected identifier

I tried a solution on here to change the first line to import { TikTokAPI, getRequestParams } from 'tiktok-api'; and receiving the following error:

import { TikTokAPI, getRequestParams } from 'tiktok-api';
       ^

SyntaxError: Unexpected token {
szdc commented 5 years ago

What version of Node are you using?

jenni commented 5 years ago

An alternative:

const TikTokAPI = require('tiktok-api');
const params = TikTokAPI.getRequestParams({...});
const api = new TikTokAPI.default(params, { signURL });
szdc commented 3 years ago

Closing as this project is no longer maintained.