That function will not work through the IPFS protocol ipfs://
. The quickest and dirtiest way to get that JSON file is to use a trusted public gateway.
You'll find the list of public gateways via the link below.
https://ipfs.github.io/public-gateway-checker/
The most important bit of information in that link is your CID
that might refer to a folder or a single file. You can link to your JSON file with that CID
using any of these public gateways.
e.g.; https://ipfs.io/ipfs/bafybeignop35wemk2eu2z34qurwusjeuri6unpyzrzeetmxs4hrwksq7dq/?filename=tokenURI.json
Please note that these gateways are not there to use in any production environment. They usually come with restrictions such as rate-limiting.
You can read more here:
https://docs.ipfs.io/concepts/ipfs-gateway/#can-websites-rely-on-the-ipfs-io-gateway-for-hosting
I also recommend you this article they have, you'll better understand the whole concept.
https://docs.ipfs.io/concepts/ipfs-gateway/#gateway-providers