Unexpected token } in JSON at position 224


I am trying to build a page where i can see my nft with one of the moralis youtube tutorial. But i am getting an error saying “Unexpected token } in JSON at position 224” when i am trying to console log my nfts with the metadata. Could you please tell me what mistake i am doing in this code?

//fetch nfts 
function fetchNFTMetadata(NFTs) {
    let promises = [];
    for (let i = 0; i < NFTs.length; i++) {
        let nft = NFTs[i];
        let id = nft.token_id;
        let hexId = parseInt(id).toString(16);
        let paddedHex = ("0000000000000000000000000000000000000000000000000000000000000000" + hexId).slice(-64);
        promises.push(fetch("https://mydomain/" + paddedHex + ".json")
            .then(res => res.json())
            .then(res => JSON.parse(res.result))
            .then(res => { nft.metadata = res })
            .then(() => { return nft; }))
    return Promise.all(promises);

//sign in function
async function initializeApp() {
    let currentUser = Moralis.User.current();
    if (!currentUser) {
        currentUser = await Moralis.Web3.authenticate();
    // Get all nfts if user signed in
    const options = {
        address: "My Contract Adress",
        chain: "bsc testnet",
    let NFTs = await Moralis.Web3API.token.getAllTokenIds(options);
    let NFTWithMetadata = await fetchNFTMetadata(NFTs.result);


in case that the error is from this line, you can use console.log for that res to see how it looks to see if it is valid json

I dont really know why i get this error but when i dont try to get metadata i am getting token information correctly

it looks like the error is from that fetchNFTMetadata function, you can add more logging there to understand what happens

Why are you parsing it twice? I don’t understand the hex/fetching URL parts as well.