New Moralis.file(..) not setting correctly?

I am following this guide and the docs

When using:

const nft = new Moralis.File(, file);
console.log('nft', nft);

The nft is returning:


Is that correct? Because when I then use:

await nft.saveIPFS();
 const imageURI = nft.ipfs();

I get Property 'ipfs' does not exist on type 'File'.ts(2339)

it may be a different method now, you can do also a console log for nft after nft.saveIPFS() to see how it looks

Here is the log

    const file = new Moralis.File(, data)
    await file.saveIPFS();


you can see there _ipfs that has the link that you want

But the type checking in TS fails, so cant compile. Managed to get around it with:

    const file = new Moralis.File(, data);
    await file.saveIPFS();

    // Save file reference to Moralis
    const jobApplication = new Moralis.Object('NFTs');
    jobApplication.set('description', this.nftForm.value.description);
    jobApplication.set('file', file);

    // Retrieve file
    const query = new Moralis.Query('NFTs');
    query.find().then(function ([application]) {
      const ipfs = application.get('file').ipfs();
      const hash = application.get('file').hash();
      console.log('IPFS url', ipfs);
      console.log('IPFS hash', hash);

I’m not sure checking that much early would give desired result when you are still in “saving” sequence, better to use .then(… syntax right behind the save().

no he use await
so the response should be exist… anyway I have checked…
it was the devs type declaration error, they didn’t define the function on File type declaration

Just ignore the type script error, the function is there

const file = new Moralis.File(, data);
await file.saveIPFS();

// @ts-ignore 
1 Like