snoowrap icon indicating copy to clipboard operation
snoowrap copied to clipboard

Incorrect nesting of children when fetching user

Open tomhooijenga opened this issue 3 years ago • 0 comments

In general, when fetching objects, some children get expanded to the corresponding object. For example: js {author: 'some_username'} => {author: RedditUser { name: 'some_username' } }

When fetching a user, there is a subreddit property that gets converted in the same way. However, the subreddit property in the response is not a string but an object, resulting in the following:

const user = await r.getUser('not_an_aardvark');

console.log(user.subreddit) // Subreddit { display_name: { ... } }
console.log(user.subreddit.display_name) // Object!
console.log(user.subreddit.display_name.display_name) // u_not_an_aardvark

It also might happen with other properties, but I haven't encountered problems with them yet.

A fix would be easy enough to make, but the bug has been happening since this was first introduced, so that might be a breaking change.

tomhooijenga avatar Feb 28 '21 19:02 tomhooijenga