Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend json content handling for referenceAsset #815

Open
Walodja1987 opened this issue Jul 27, 2023 · 0 comments
Open

Extend json content handling for referenceAsset #815

Walodja1987 opened this issue Jul 27, 2023 · 0 comments

Comments

@Walodja1987
Copy link
Collaborator

Currently, only URLs that end with .json are handled as json. However, there are also URLs, that do not end with .json but still have json content. Here an example: https://nftstorage.link/ipfs/bafkreic5xs3jg3m4poqqikwyslatiyknkevtwyqqzlouokwlslgkiu5nga

Extend the current check by checking whether the content is of json format by parsing the the response data via JSON.parse.

Dummy code:

async function isJson(url: string): Promise<boolean> {
try {
const response = ...

// Try to parse the content as JSON
try {
JSON.parse(response.data);
return true;
} catch (error) {
return false;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant