This repository was archived by the owner on Mar 10, 2020. It is now read-only.
This repository was archived by the owner on Mar 10, 2020. It is now read-only.
Unexpected token < in JSON at position 0 #905
Closed
Description
Hey IPFS team, I have a strange error when trying to add new files to IPFS.
Here's my code:
`
const ipfsClient = require('ipfs-http-client');
const ipfs = ipfsClient("ipfs.infura.io", "5001", {protocol: "http"});
let testFile = fs.readFileSync("./backend/images/imagen.jpg");
ipfs.add(testFile, (err, res) => {
if(err) { console.error(err); }
});
`
It always returns the error "SyntaxError: Unexpected token < in JSON at position 0".
The value of testFile variable is " <Buffer ff d8 ff e0 00 10 4a 46 49 46 00 01 01 00 00 01 00 01 00 00 ff fe 00 3b 43 52 45 41 54 4f 52 3a 20 67 64 2d 6a 70 65 67 20 76 31 2e 30 20 28 75 73 69 ... > "
I hope you can help me :(