News

More details and API reference: News

Reference

Methods

.publish

.publish(content, author, timestamp?)

Publish news on iPear.

More details and API reference: (out.) Publish

Parameters

KeyTypeDescription
contentstring
required
News content (1-512 characters)
authorstring
required
Author of the content (1-64 characters)
timestampnumberDate (unix ms, UTC)

Returns

Promise<string> - string is unique identifier of the news.

Example

Usage

app.news.publish({ 
    content: "A heat wave is expected in the next few days. Stay safe.", 
    author: 'Laura Quigley', 
    timestamp: 1672527600000
}).then((id) => {
    console.log('my news id', id);
}).catch((error) => {
    console.log('error', error);
});

Result

"92003acb-b4f6-47fd-8c5d-c8eef2c7e124"

.remove

.remove(id)

Remove a news published on iPear.

More details and API reference: (out.) Remove

Parameters

KeyTypeDescription
idstring
required
News identifier (36 characters)

Returns

Promise<boolean> - Has been deleted (throw error on fail).

Example

Usage

app.news.remove("92003acb-b4f6-47fd-8c5d-c8eef2c7e124").then((deleted) => {
    console.log('news deleted:', deleted);
}).catch((error) => {
    console.log('error', error);
});

Result

true

Powered by Doctave