EML Docs

News

News fetches articles and categories published in EML AdminTool for display in the launcher’s news feed.

Warning

News requires an EML AdminTool instance. It is not available in agnostic mode.

import { News } from 'eml-lib'

getNews()

async function getNews() {
  const news = new News('https://at.myserver.com')

  try {
    const articles = await news.getNews()
    renderNewsFeed(articles)
  } catch (err) {
    console.error(err)
  }
}

Constructor

ParameterTypeDescriptionRequired?
urlstringThe URL of your EML AdminTool instance.Yes

getNews() method

Fetches all published news articles.

Returns: Promise<INews[]>

Throws: FETCH_ERROR — If the request to EML AdminTool fails.

getCategories() method

Fetches all news categories.

Returns: Promise<INewsCategory[]>

Throws: FETCH_ERROR — If the request to EML AdminTool fails.

getNewsByCategory() method

Warning

This method is deprecated and returns an empty array. Filter articles client-side instead: news.getNews().then(articles => articles.filter(a => a.categoryId === id)).