# getItems method

Future <Result<PubSubError, List <PubSubItem>>> getItems(

1. JID jid,
2. String node,
3. {int? maxItems}

)

## Implementation

    Future<Result<PubSubError, List<PubSubItem>>> getItems(
      JID jid,
      String node, {
      int? maxItems,
    }) async {
      final result = (await getAttributes().sendStanza(
        StanzaDetails(
          Stanza.iq(
            type: 'get',
            to: jid.toString(),
            children: [
              XMLNode.xmlns(
                tag: 'pubsub',
                xmlns: pubsubXmlns,
                children: [
                  XMLNode(
                    tag: 'items',
                    attributes: {
                      'node': node,
                      if (maxItems != null) 'max_items': maxItems.toString(),
                    },
                  ),
                ],
              ),
            ],
          ),
          shouldEncrypt: false,
        ),
      ))!;

      if (result.attributes['type'] != 'result') {
        return Result(getPubSubError(result));
      }

      final pubsub = result.firstTag('pubsub', xmlns: pubsubXmlns);
      if (pubsub == null) {
        return Result(getPubSubError(result));
      }

      final items = pubsub.firstTag('items')!.children.map((item) {
        return PubSubItem(
          id: item.attributes['id']! as String,
          payload: item.children[0],
          node: node,
        );
      }).toList();

      return Result(items);
    }