Skip to content
This repository has been archived by the owner on Mar 17, 2024. It is now read-only.

subreddit.getWikiPage(args).fetch() returns promise resolved with malformed WikiPage object #351

Open
jamesrswift opened this issue Jan 15, 2022 · 1 comment

Comments

@jamesrswift
Copy link

jamesrswift commented Jan 15, 2022

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.

@iMrDJAi
Copy link

iMrDJAi commented Apr 9, 2022

@Jamesxx Fixed by adding:

_transformApiResponse (res: WikiPage) {
  res.title = this.title
  res.subreddit = this.subreddit
  return res
}

...to the WikiPage class.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants