23-12-30 일단계 작업 종료와 이후 작업을 위한 steemAPI getDiscussionsByAuthorBeforeDate 살펴보기
1단계 작업을 마쳤으니 일단 배포를 위한 작업을 하려 한다. 어떤 방식으로 할 것인가는 좀 더 생각해보아야 하겠다.
일단 다음 작업을 위한 스팀 API를 살펴보았다.
getDiscussionsByAuthorBeforeDate 함수
Steem API에서 특정 저자(author)가 작성한 게시물들을 특정 날짜 이전까지 조회할 때 사용됩니다.
이 함수는 특히 시간 기반의 쿼리가 필요할 때 유용하며, 사용자가 특정 기간 동안 작성한 게시물들을 가져오고 싶을 때 적합합니다.
getDiscussionsByAuthorBeforeDate 사용 시나리오:
특정 기간 동안의 게시물 조회: 사용자가 특정 날짜 이전에 작성한 게시물들을 조회하고자 할 때 사용합니다. 예를 들어, 2021년 1월 1일 이전에 작성된 모든 게시물을 조회하고 싶을 때 이 함수를 사용할 수 있습니다.페이징 및 아카이브: 사용자의 블로그 내역을 페이지화하거나 과거 게시물을 아카이브 형태로 보여줄 때 유용합니다. 예를 들어, 과거 게시물을 연도별 또는 월별로 분류하여 보여주고 싶을 때 사용할 수 있습니다.
함수 사용 예시:
import React, { useState, useEffect } from 'react';
import steem from 'steem';
const BlogPosts = ({ username }) => {
const [posts, setPosts] = useState([]);
const [loading, setLoading] = useState(true);
const [error, setError] = useState(null);
useEffect(() => {
// 2022년의 시작과 끝을 나타내는 날짜 설정
const startOfYear = new Date('2022-01-01');
const endOfYear = new Date('2022-12-31');
steem.api.getDiscussionsByAuthorBeforeDate(
username,
"", // 마지막 게시물의 permlink, 첫 요청시 "" 사용
endDate.toISOString().split('T')[0],
5, // 가져올 게시물 수
(err, result) => {
if (err) {
setError(err);
setLoading(false);
} else {
setPosts(result);
setLoading(false);
}
}
);
}, [username]);
if (loading) return
if (error) return
return ()
이 코드는 지정된 사용자의 지난 1년간의 게시물을 최대 5개까지 불러옴. endDate를 현재 날짜로, startDate를 1년 전 날짜로 설정하여 해당 기간 동안의 게시물들을 조회.
Thank you, friend!


I'm @steem.history, who is steem witness.
Thank you for witnessvoting for me.
please click it!
(Go to https://steemit.com/~witnesses and type fbslo at the bottom of the page)
The weight is reduced because of the lack of Voting Power. If you vote for me as a witness, you can get my little vote.
This post has been upvoted by @italygame witness curation trail
If you like our work and want to support us, please consider to approve our witness
Come and visit Italy Community