Unexpected changes in api response object names (expected = "contractualRules", received = "s:contractualRules")
Arthur Mougin
1
Reputation point
Hi all,
When implementing Bing Web Search on a Nuxt3 project, I noticed that fetching the API returned valid objects with a weird twist.
Types are now "s:ImageObject" and some randomly selected object properties also include the s: as a prefix (like "s:thumbnailUrl").
It's an issue as I am working with Typescript, and such names are a pain to use (a.s:b -> a["s.b"]).
I fixed it by stringlifying, removing the unwanted prefix, and reparsing the response object.
const uncleanString = JSON.stringify(uncleanData);
const cleanString = uncleanString.replaceAll("\"s:","\"")
const cleanData = JSON.parse(cleanString)
Do you know where that could come from?
Sign in to answer