Skip to content

Commit

Permalink
refactor: use require to support older node versions
Browse files Browse the repository at this point in the history
  • Loading branch information
TheUnderScorer committed Jul 13, 2023
1 parent 46bf728 commit 4a8a63f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
33 changes: 20 additions & 13 deletions example/index.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
import { FingerprintJsServerApiClient, Region } from '@fingerprintjs/fingerprintjs-pro-server-api';
import 'dotenv/config';
const {
FingerprintJsServerApiClient,
Region,
} = require('@fingerprintjs/fingerprintjs-pro-server-api');
require('dotenv').config();

const apiKey = process.env.API_KEY;
const visitorId = process.env.VISITOR_ID;
const requestId = process.env.REQUEST_ID;

const client = new FingerprintJsServerApiClient({ region: Region.Global, apiKey: apiKey });

try {
const [visitorHistory, event] = await Promise.all([
client.getVisitorHistory(visitorId),
client.getEvent(requestId),
]);
async function main() {
try {
const [visitorHistory, event] = await Promise.all([
client.getVisitorHistory(visitorId),
client.getEvent(requestId),
]);

console.log(JSON.stringify(visitorHistory));
console.log(JSON.stringify(event));
} catch (e) {
console.error(e);
process.exit(1);
console.log(JSON.stringify(visitorHistory));
console.log(JSON.stringify(event));
} catch (e) {
console.error(e);
process.exit(1);
}

process.exit(0);
}

process.exit(0);
void main();
1 change: 0 additions & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "fingerprintjs-pro-server-api-node-sdk-example",
"version": "1.0.0",
"description": "",
"type": "module",
"main": "index.js",
"private": true,
"scripts": {
Expand Down

0 comments on commit 4a8a63f

Please sign in to comment.