react js Module not found: Can't resolve 'file-saver'

11.6k Views Asked by At

I'm following a tutrotial and all off a sudden i'm getting this error . I've tried all solution and reinstall module. but in other class the same code work

this is my code

import fileSaver from 'file-saver';

uploadPensiun(event) {
        const files = event.target.files
        const formData = new FormData()
        formData.append('Pensiun', files)
        fetch('http://localhost:5000/uploadpensiun', {
            method: 'POST',
            body: 'Pensiun',
            headers: {
                'Accept': 'application/json',
                'Content-Type': 'multipart/form-data'
            },
        })
        .then(res => res.json())
        .then(data => console.log(data))
        .catch((err) => console.log(err));
        
    }

anyone can help me please?

1

There are 1 best solutions below

0
On BEST ANSWER

Install the file-saver

with npm:

npm install file-saver

or with yarn:

yarn add file-saver