Hello, I am using the Moralis SDK and node/express to display a specific user’s nft. I followed this tutorial, but I am getting a “failed to load resource server responded with a status of 404” when I test the route. Does anyone know where I am going wrong? Thanks!
const router = require('express').Router()
const Moralis = require('moralis/node')
const fixURL = require('../utils/fixURL')
const axios = require('axios')
require('dotenv').config()
const serverUrl = process.env.serverUrl
const appId = process.env.appId
router.get('/dashboard/nfts/1', async (req, res) => {
try {
const options = { chain: 'eth', address: '0x8a08e3Ce6CED24d376a13C544E45d4DDa02FaFEA' }
await Moralis.start({ serverUrl, appId })
const userNFTs = await Moralis.Web3API.account.getNFTs(options)
userNFTs.forEach(async function (nft) {
let url = fixURL(nft.token_uri)
const { data } = await axios.get(url)
res.json(data)
})
} catch (err) {
res.status(500).json({ error: err })
}
})
In my code for fixURL I have
module.exports = function fixURL(url) {
if (url.startsWith("ipfs")) {
return 'https://ipfs.moralis.io:2053/ipfs/' + url.split('ipfs://ipfs/').slice(-1)
} else {
return url + '?format=json'
}
}