Hello, I am so new to this JavaScript , I hope someone can help me, I am trying to import some modules that will help me to compress images but I get an error:
Uncaught SyntaxError: Unexpected identifier
This is my code:
import axios from 'axios';
import ImageCompressor from 'image-compressor.js';
document.getElementById('files').addEventListener('change', (e) => {
const file = e.target.files[0];
if (!file) {
return;
}
new ImageCompressor(file, {
quality: .6,
success(result) {
const formData = new FormData();
formData.append('files', result, result.name);
// Send the compressed image file to server with XMLHttpRequest.
axios.post('/path/to/upload', formData).then(() => {
console.log('Upload success');
});
},
error(e) {
console.log(e.message);
},
});
});
<input type="file" id="files" name="image" multiple="true" accept=".png, .jpg, .jpeg"/>
This is the error that comes to me: