Fetch

Usage

In order to retrieve a list of Post, you can use the Get() function provided by the aggregate object given in aleph-sdk-ts import.

import { messages } from 'aleph-sdk-ts';

// Or used optimized import

import { Get as getPost } from 'aleph-sdk-ts/dist/messages/post';
import { Get as getPost } from 'aleph-sdk-ts/dist/messages/post';


(async () => {
  await getPost({
      types: 'mytype',
      APIServer: "https://api2.aleph.im"
    })
})();

Parameters

Return

The function returns an object containing a posts array as well as details on the number of posts and pages returned:

{ 
  posts: [ { ... }, { ... }, { ... }], 
  pagination_page: 1,
  pagination_total: 3,
  pagination_per_page: 200,
  pagination_item: 'posts'
 }

The return value from the example above:

Return value example for getPost
{
  posts: [
    {
      chain: 'ETH',
      item_hash: 'ba789cbcc57ab356962a5565626b5fda2504f4a5723cf3828c6c5d5ef4b19b3c',
      sender: '0xd1b7ee78186Dd2a92DDc0180DDa5738ABB16E9CB',
      type: 'amend',
      channel: 'TEST',
      confirmed: false,
      content: [Object],
      item_content: '{"type":"amend","address":"0xd1b7ee78186Dd2a92DDc0180DDa5738ABB16E9CB","content":{"body":"first content updated"},"time":1667833519.319,"ref":"27f5bccbde6d41f3460c68d32083429a098d5d78a16539303670c6cdf71cbfc0"}',
      item_type: 'inline',
      signature: '0x43286d7bcf4bd0b39b93f422e0a345ccba945bc4d7f9491d20a0be2a4775399b167f4560eb9cd13f18004c9ca29ba67b32523275ab31947b34030535f6fbea4f1b',
      size: 209,
      time: 1667833519.319,
      original_item_hash: '27f5bccbde6d41f3460c68d32083429a098d5d78a16539303670c6cdf71cbfc0',
      original_signature: '0x1f575376780c3b11e31bee349a587a251d7a3bbef2bc6a884246992c02ba19972db2cda27b415d434bcdf76b726448ee2f870c13100eaf2808939426df85775e1b',
      original_type: 'mytype',
      hash: '27f5bccbde6d41f3460c68d32083429a098d5d78a16539303670c6cdf71cbfc0',
      address: '0xd1b7ee78186Dd2a92DDc0180DDa5738ABB16E9CB',
      ref: '27f5bccbde6d41f3460c68d32083429a098d5d78a16539303670c6cdf71cbfc0'
    }
  ],
  pagination_page: 1,
  pagination_total: 1,
  pagination_per_page: 200,
  pagination_item: 'posts'
}

The original_ fields are here in case you amended the post.

This function retrieves the latest version of all posts. If a post was updated twice after the original version was created, only the last updated post will show.

In the response, the item_content object attributes (type, content, address, time) are merged in the post message object to be easily reachable. Item_content is still available in the message object as well.

Last updated