Search code examples
node.jsreactjsfingerprint

fingerpint input using react , node , mysql


Can anyone let me know how can we take user fingerprint and save those data in mysql server

I came to know about fingerprintjs library for react. Is that a right solution for me to use that api ?

Actually Im in need to take fingerprint and send those data to mysql server and update the record based on it. But currently I'm stuck at this fingerprint part. I want to manually take the fingerprint and set ID for it in database and then start matching those fingerprints later.

Can anyone suggest how to proceed this ?


Solution

  • here you go

    import { useEffect } from 'react';
    import FingerprintJS from '@fingerprintjs/fingerprintjs';
    
    const FingerprintCollector = () => {
      useEffect(() => {
        const collectFingerprint = async () => {
          const fp = await FingerprintJS.load();
          const result = await fp.get();
    
          // Assuming you have an API to send the fingerprint data to your server
          // Replace 'your-api-endpoint' with the actual endpoint to store the data.
          fetch('your-api-endpoint', {
            method: 'POST',
            headers: {
              'Content-Type': 'application/json',
            },
            body: JSON.stringify({ fingerprint: result.visitorId }),
          });
        };
    
        collectFingerprint();
      }, []);
    
      return null;
    };
    
    export default FingerprintCollector;