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

[TS] Page.content() has incorrect return type #164

Open
Angoooose opened this issue Jan 12, 2022 · 3 comments · Fixed by mattvick/wiki#1 · May be fixed by #166
Open

[TS] Page.content() has incorrect return type #164

Angoooose opened this issue Jan 12, 2022 · 3 comments · Fixed by mattvick/wiki#1 · May be fixed by #166
Labels

Comments

@Angoooose
Copy link

Page.content() is set to return a promise of a string, however this is not always the case. Sometimes (more often than not it seems) it returns a promise for an array of page sections.

wiki().page('January_12').then(p => p.content()).then(async res => {
    console.log(res);
});
[
  {
    title: 'Events',
    content: '',
    items: [ [Object], [Object], [Object] ]
  },
  {
    title: 'Births',
    content: '',
    items: [ [Object], [Object], [Object] ]
  },
  {
    title: 'Deaths',
    content: '',
    items: [ [Object], [Object], [Object] ]
  },
  {
    title: 'Holidays and observances',
    content: 'Christian feast day:\n' +
      'Aelred of Rievaulx\n' +
      'Benedict Biscop\n' +
      'Bernard of Corleone\n' +
      'Marguerite Bourgeoys\n' +
      'Tatiana\n' +
      'January 12 (Eastern Orthodox liturgics)\n' +
      'Memorial Day (Turkmenistan)\n' +
      'National Youth Day (India)\n' +
      "Prosecutor General's Day (Russia)\n" +
      'Zanzibar Revolution Day (Tanzania)\n' +
      'Aseggwas Amaziɣ, ⴰⵙⴳⴳⴰⵙ ⴰⵎⴰⵣⵉⵖ (Algeria)'
  },
  { title: 'References', content: '' },
  {
    title: 'External links',
    content: 'BBC: On This Day\n' +
      '\n' +
      'The New York Times: On This DayHistorical Events on January 12\n' +
      'Today in Canadian History'
  }
]
@dijs dijs added the bug label Jan 13, 2022
@dijs
Copy link
Owner

dijs commented Jan 13, 2022

Thanks for the example. I will look info this.

@dijs
Copy link
Owner

dijs commented Jan 14, 2022

After looking at this again, the function seems to be doing exactly as described in the docs: https://dijs.github.io/wiki/WikiPage.html#content

It parses the extracted content from sections on the page.

If you would like to transform the results into a string , i am sure that would not be difficult.

@Angoooose
Copy link
Author

The method acts as it should, however its return type is incorrect. It's said to return a string while it actually returns an array.

(method) Page.content(): Promise<string>
Text content from page

@returns

@memberof — Page

@Angoooose Angoooose linked a pull request Jan 18, 2022 that will close this issue
mattvick added a commit to mattvick/wiki that referenced this issue Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants