Converse converse.js

Namespace: contacts

_converse.api.contacts

Methods

(static) add(jid, nameopt)

Add a contact.

Parameters:
Name Type Attributes Description
jid string

The JID of the contact to be added

name string <optional>

A custom name to show the user by in the roster

Source:
Examples
_converse.api.contacts.add('buddy@example.com')
_converse.api.contacts.add('buddy@example.com', 'Buddy')

(static) add(jid, nameopt)

Add a contact.

Parameters:
Name Type Attributes Description
jid string

The JID of the contact to be added

name string <optional>

A custom name to show the user by in the roster

Source:
Examples
_converse.api.contacts.add('buddy@example.com')
_converse.api.contacts.add('buddy@example.com', 'Buddy')

(static) get() → {promise}

This method is used to retrieve roster contacts.

Source:
Returns:

Promise which resolves with the _converse.RosterContact (or an array of them) representing the contact.

Type
promise
Examples
// Fetch a single contact
_converse.api.listen.on('rosterContactsFetched', function () {
    const contact = await _converse.api.contacts.get('buddy@example.com')
    // ...
});
// To get multiple contacts, pass in an array of JIDs:
_converse.api.listen.on('rosterContactsFetched', function () {
    const contacts = await _converse.api.contacts.get(
        ['buddy1@example.com', 'buddy2@example.com']
    )
    // ...
});
// To return all contacts, simply call ``get`` without any parameters:
_converse.api.listen.on('rosterContactsFetched', function () {
    const contacts = await _converse.api.contacts.get();
    // ...
});

(static) get() → {promise}

This method is used to retrieve roster contacts.

Source:
Returns:

Promise which resolves with the _converse.RosterContact (or an array of them) representing the contact.

Type
promise
Examples
// Fetch a single contact
_converse.api.listen.on('rosterContactsFetched', function () {
    const contact = await _converse.api.contacts.get('buddy@example.com')
    // ...
});
// To get multiple contacts, pass in an array of JIDs:
_converse.api.listen.on('rosterContactsFetched', function () {
    const contacts = await _converse.api.contacts.get(
        ['buddy1@example.com', 'buddy2@example.com']
    )
    // ...
});
// To return all contacts, simply call ``get`` without any parameters:
_converse.api.listen.on('rosterContactsFetched', function () {
    const contacts = await _converse.api.contacts.get();
    // ...
});

_converse.api.contacts

Methods

(static) add(jid, nameopt)

Add a contact.

Parameters:
Name Type Attributes Description
jid string

The JID of the contact to be added

name string <optional>

A custom name to show the user by in the roster

Source:
Examples
_converse.api.contacts.add('buddy@example.com')
_converse.api.contacts.add('buddy@example.com', 'Buddy')

(static) add(jid, nameopt)

Add a contact.

Parameters:
Name Type Attributes Description
jid string

The JID of the contact to be added

name string <optional>

A custom name to show the user by in the roster

Source:
Examples
_converse.api.contacts.add('buddy@example.com')
_converse.api.contacts.add('buddy@example.com', 'Buddy')

(static) get() → {promise}

This method is used to retrieve roster contacts.

Source:
Returns:

Promise which resolves with the _converse.RosterContact (or an array of them) representing the contact.

Type
promise
Examples
// Fetch a single contact
_converse.api.listen.on('rosterContactsFetched', function () {
    const contact = await _converse.api.contacts.get('buddy@example.com')
    // ...
});
// To get multiple contacts, pass in an array of JIDs:
_converse.api.listen.on('rosterContactsFetched', function () {
    const contacts = await _converse.api.contacts.get(
        ['buddy1@example.com', 'buddy2@example.com']
    )
    // ...
});
// To return all contacts, simply call ``get`` without any parameters:
_converse.api.listen.on('rosterContactsFetched', function () {
    const contacts = await _converse.api.contacts.get();
    // ...
});

(static) get() → {promise}

This method is used to retrieve roster contacts.

Source:
Returns:

Promise which resolves with the _converse.RosterContact (or an array of them) representing the contact.

Type
promise
Examples
// Fetch a single contact
_converse.api.listen.on('rosterContactsFetched', function () {
    const contact = await _converse.api.contacts.get('buddy@example.com')
    // ...
});
// To get multiple contacts, pass in an array of JIDs:
_converse.api.listen.on('rosterContactsFetched', function () {
    const contacts = await _converse.api.contacts.get(
        ['buddy1@example.com', 'buddy2@example.com']
    )
    // ...
});
// To return all contacts, simply call ``get`` without any parameters:
_converse.api.listen.on('rosterContactsFetched', function () {
    const contacts = await _converse.api.contacts.get();
    // ...
});