Right at this timestamp
my chrome console spits out
main.js:97 Uncaught (in promise) TypeError: nftFile.saveIPFS is not a function
at HTMLButtonElement.createItem (main.js:97)
The code is more or less verbatim
line 97 is
await nftFile.saveIPFS();
It’s probably unnecessary but i’ll post the whole function as is atm
createItem = async () => {
if (createItemFile.files.length == 0){
alert("Please select a file!");
return;
} else if (createItemNameField.value.lenth == 0){
alert("Please give the item a name!");
return;
}
const nftFile = new Moralis.File("nftFile.jpg", createItemFile.files[0]);
await nftFile.saveIPFS();
const nftFilePath = nftFile.ipfs();
const nftFileHash = nftFile.hash();
const metadata = {
name: createItemNameField.value,
description: createItemDescriptionField.value,
nftFilePath: nftFilePath,
nftFileHash: nftFileHash
};
const nftFileMetadataFile = new Moralis.File("metadata.json", {base64 : btoa(JSON.stringify(metadata))});
await nftFileMetadataFile.saveIPFS();
const nftFileMetadataFilePath = nftFileMetadataFile.ipfs();
const nftFileMetadataFileHash = nftFileMetadataFile.hash();
// Simple syntax to create a new subclass of Moralis.Object.
const Item = Moralis.Object.extend("Item");
// Create a new instance of that class.
const item = new Item();
item.set("name", createItemNameField.value)
item.set("description", createItemDescriptionField.value)
item.set("nftFilePath", nftFilePath)
item.set("nftFileHash", nftFileHash)
item.set("MetadataFilePath", nftFileMetadataFilePath)
item.set("MetadataFileHash", nftFileMetadataFileHash)
await item.save();
console.log(item)
}
Thanks!