Example in README.md to fetch Ethereum asset does not work
Closed this issue ยท 3 comments
Describe the bug
Upon running the file, I receive an error stating:
SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
...
As well as
...
(node:47001) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 22 terminated listeners added to [Fetch]. Use emitter.setMaxListeners() to increase limit
It seems that the fetch request is able to return information about
โ
Solana based assets: GrWNH9qfwrvoCEoTm65hmnSh4z3CD96SfhtfQY6ZKUfY, and not
โ Ethereum based assets: 0x5A8443f456f490dceeAD0922B0Cc89AFd598cec9
like in the example.
It is expected to get the JSON data from the Ethereum based asset, just like the Solana based asset.
To Reproduce
Run the following installation commands above. The reason is that I am testing out the fetching aspect as a utility file, which will be imported into the main project.
node fetchNft.ts
The code is as follows:
const { FetchNFTClient } = require("@audius/fetch-nft");
// Initialize fetch client
const fetchClient = new FetchNFTClient();
// Fetching all collectibles for the given wallets
fetchClient
.getCollectibles({
ethWallets: ["0x5A8443f456f490dceeAD0922B0Cc89AFd598cec9"],
solWallets: ["GrWNH9qfwrvoCEoTm65hmnSh4z3CD96SfhtfQY6ZKUfY"],
})
.then((res) => console.log(res));
The error in the terminal is as follows:
SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
at JSON.parse (<anonymous>)
at parseJSONFromBytes (node:internal/deps/undici/undici:6662:19)
at successSteps (node:internal/deps/undici/undici:6636:27)
at node:internal/deps/undici/undici:1236:60
at node:internal/process/task_queues:140:7
at AsyncResource.runInAsyncScope (node:async_hooks:206:9)
at AsyncResource.runMicrotask (node:internal/process/task_queues:137:8)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) https://api.opensea.io/api/v1/events?account_address=0x5A8443f456f490dceeAD0922B0Cc89AFd598cec9&limit=300&event_type=transfer&only_opensea=false
SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
at JSON.parse (<anonymous>)
at parseJSONFromBytes (node:internal/deps/undici/undici:6662:19)
at successSteps (node:internal/deps/undici/undici:6636:27)
at node:internal/deps/undici/undici:1236:60
at node:internal/process/task_queues:140:7
at AsyncResource.runInAsyncScope (node:async_hooks:206:9)
at AsyncResource.runMicrotask (node:internal/process/task_queues:137:8)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) https://api.opensea.io/api/v1/events?account_address=0x5A8443f456f490dceeAD0922B0Cc89AFd598cec9&limit=300&event_type=created&only_opensea=false
SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
at JSON.parse (<anonymous>)
at parseJSONFromBytes (node:internal/deps/undici/undici:6662:19)
at successSteps (node:internal/deps/undici/undici:6636:27)
at node:internal/deps/undici/undici:1236:60
at node:internal/process/task_queues:140:7
at AsyncResource.runInAsyncScope (node:async_hooks:206:9)
at AsyncResource.runMicrotask (node:internal/process/task_queues:137:8)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) https://api.opensea.io/api/v1/assets?owner=0x5A8443f456f490dceeAD0922B0Cc89AFd598cec9&limit=50
{
ethCollectibles: {},
solCollectibles: {
GrWNH9qfwrvoCEoTm65hmnSh4z3CD96SfhtfQY6ZKUfY: [ [Object], [Object], [Object], [Object] ]
}
}
(node:47001) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 22 terminated listeners added to [Fetch]. Use emitter.setMaxListeners() to increase limit
(Use `node --trace-warnings ...` to show where the warning was created)
Supporting Media
...Expected behavior
It is expected to get the JSON data from the Ethereum based asset, just like the Solana based asset.
Your environment
OS: MacOS 13.4 - Ventura
Node version: V20.5.0
Npm version: 9.8.1
Browser name and version: Chrome 118.0.5993.70
Additional context:
Perhaps the query for Ethereum requires an OpenSea configuration. It is not clear from the documentation.
Upon omitting the Ethereum based request, the information is retrieved:
{
ethCollectibles: {},
solCollectibles: {
GrWNH9qfwrvoCEoTm65hmnSh4z3CD96SfhtfQY6ZKUfY: [ [Object], [Object], [Object], [Object] ]
}
}
(node:48876) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 22 terminated listeners added to [Fetch]. Use emitter.setMaxListeners() to increase limit
(Use `node --trace-warnings ...` to show where the warning was created)
using the code:
const { FetchNFTClient } = require("@audius/fetch-nft");
// Initialize fetch client
const fetchClient = new FetchNFTClient();
// Fetching all collectibles for the given wallets
fetchClient
.getCollectibles({
// ethWallets: ["0x5A8443f456f490dceeAD0922B0Cc89AFd598cec9"], --- OMITTED
solWallets: ["GrWNH9qfwrvoCEoTm65hmnSh4z3CD96SfhtfQY6ZKUfY"],
})
.then((res) => console.log(res));
The error seems to only come from getting the Ethereum asset.
A similar issue occurs with the following example from:
https://github.com/AudiusProject/fetch-nft/blob/main/examples/node/index.js
Where the Solana assets are found, but not the Ethereum assets.
Upon speaking with @raymondjacobson, the Ethereum asset issue is around the need for an OpenSea API key
See https://github.com/AudiusProject/fetch-nft#usage-with-configs
to add a specific opensea API key