Steem.js Example #3. Get Posts more than 20 posts, pagination.
WordPress Post : http://junn.in/archives/575
Github source :
- https://github.com/junn279/steemjs_example/blob/master/steem03_1.php (lite version)
- https://github.com/junn279/steemjs_example/blob/master/steem03.php
Continue to our previous example, this time I’ll introduce get_discussions_… functions.
I don’t know why, but functions are named like as below.
지난 포스팅에 이어, get_discussion 함수를 이용해 20개 이상의 자료, 연속되는 자료 받기를 확인해볼 예정이다. 함수 이름을 왜 discussion이라고 했는지 잘 모르겠다.
At this time, make a source like this. A Little bit different from previous sources, but this is more effective to view sequential 10, 20 (next 10) posts. I used getDiscussionsByCreated. Literally, byCreated means ‘retrieve posts in the order when they were created.
Look at ‘query’ and number of ‘limit’ is 11 not 10. Last one is for ‘retrieve next 10 posts’
기본 틀을 위과 같이 잡는다. 일단 불러오는 갯수를 11로 한 것은, 마지막 데이터는 다음 10개를 불러어오기 위한 데이터로 필요하기 때문이다.
As member variation of ‘query’ object, set start_author and start_permlink from last 11th post(but array index starts from number zero, so number 10 indicate the 11th post).
And then if you watch the developer console, you can see the retrieved posts.
But in this case, you should not put ‘inner query2~steem.api.getDis.. function’ out of first getDiscussionBy… function. Because steem.api is running synchronously.
I’m sure there is another way to run these sequential functions asynchronously. But I don’t know yet.
받아온 데이터의 마지막(11번째; array에서 index는 10) 포스트의 자료를 이용해서 다음 내용을 불러온다. 함수 내부에 다시 함수를 넣어야하는 이유는 동기화로 진행되는 함수이기 때문에 밖으로 뺄 경우 제대로된 변수값이 세팅되지 않기 때문이다.
Finally, I made a source using this function, put a button and by using it, we can get next 10 posts.
마지막으로 만든 소스는 버튼을 이용해서 계속적으로 포스트를 연장하는 소스이다.
https://github.com/junn279/steemjs_example/blob/master/steem03.php
There is a ‘click’ button, and then you can get next 10 posts. These are match to what we can see through https://steemit.com/tag/kr perfectly. (Be sure to be different from my result)
아래와 같은 결과를 만들어내었다.
Leave Steem.js Example #3. Get Posts more than 20 posts, pagination. to:
Read more #steem posts
Best Posts From junn
We have not curated any of junn's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From junn
- 이스라엘 이야기 - 출산율 3.16명인 나라, 우리와 무엇이 차이일까?
- 데이터 시각화용 라이브러리 d3.js 에 대해서 알아봤습니다.
- Make your Steemit Blog Post 업데이트 (이미지 제외 추가)
- [의학] 귀를 파지 마세요 (원제 : 귀지의 중요성)
- Make your Steemit Blog Post List / Introduction
- Make your Steemit Blog Post List / 내 블로그 리스트 만들기 (예시 페이지)
- [의학] 칼슘보충제는 항상 옳다? (원제: 건강에 대한 잘못된 믿음들)
- [Jazz] Nat King Cole 'El Bodeguero' 및 가사, Jim Carrey 'Cuban Pete'
- Steem 글을 HTML 및 HTML 소스로 보여주는 페이지를 만들었습니다.(Steem to HTML page, source code)
- Steem Markdown to HTML <업데이트> Table, Linebreak(줄바꿈) 및 기타 오류 문제