首页 > 解决方案 > 指纹js指纹.get不是一个函数

问题描述

目前我在我之前的项目中遇到指纹问题我以这种方式解决了这个问题:

 const test = async (req, res, next) => {
    // other code   
    
    const FingerprintJS = require('@fingerprintjs/fingerprintjs');
    const store = require('store')

    FingerprintJS.get({
      preprocessor: function(key, value) {
          return value
      }
    },function(components){
        let values = components.map(function (component) { return component.value });
        let device_id = FingerprintJS.x64hash128(values.join(''), 31);
        store.set('print', { device: device_id })
    });

    await new Promise(resolve => setTimeout(resolve, 1000));
    
    // other code
    
  };

但现在我无法将其设置为工作.. 我在 console.log 中遇到错误:

(node:4940) UnhandledPromiseRejectionWarning: TypeError: FingerprintJS.get is not a function
    at login (C:\Users\PC06\Desktop\project\backend\controllers\clients-controllers.js:53:17)
(node:4940) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:4940) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a
non-zero exit code.

对此有什么帮助吗?

标签: javascriptnode.jsfingerprint

解决方案


推荐阅读