snoowrap
snoowrap copied to clipboard
subreddit.getWikiPage(args).fetch() returns promise resolved with malformed WikiPage object
In the example code below:
mySubreddit.getWikiPage(args).fetch().then( wiki: Snoowrap.WikiPage ) =>{
/// Do Stuff
wiki.edit({
text: edittedWikiPage,
reason: 'reason',
});
})
produces the below error:
url: "r/".concat(_this4.subreddit.display_name, "/api/wiki/edit"),
^
TypeError: Cannot read properties of undefined (reading 'display_name')
Internally, _this4.subreddit
appears to be undefined, with no opportunity to remedy.
@JamesxX Fixed by adding:
_transformApiResponse (res: WikiPage) {
res.title = this.title
res.subreddit = this.subreddit
return res
}
...to the WikiPage class.