Random User Generator | Home
Copyright Notice All randomly generated photos were hand picked from the authorized section of UI Faces. Please visit UI Faces FAQ for more information regarding how you can use these faces.
randomuser.me
랜덤한 사람들의 이미지들을 넣을 수 있는 무료 API
utils 폴더에 random.ts로 만들어놓으면 불러다 쓰기 편함
export const getRandomImage = (index: number) => {
return `https://randomuser.me/api/portraits/med/men/${index}.jpg`;
};
사용시에는 src에서 index 만 매개변수로 전달해주면됨
그리고 채팅방에서 잘 사용되는
몇시간전까지 해당 유저가 온라인 상태였는지 표시하기 쉽도록
라이브러리를 사용한다.
https://www.npmjs.com/package/javascript-time-ago
javascript-time-ago
Localized relative date/time formatting. Latest version: 2.5.10, last published: 4 months ago. Start using javascript-time-ago in your project by running `npm i javascript-time-ago`. There are 229 other projects in the npm registry using javascript-time-ag
www.npmjs.com
한국어로 할거기에 ko-KR 로 입력한다.
timeAgo.format으로 변환할 날짜를 감싸주는데
date를 파싱해서 Timeage 형식으로 포맷팅해줌
'FRONTEND > Next.js' 카테고리의 다른 글
[Next.js 14 + Supabase ] Supabase realtime (1) (0) | 2024.08.18 |
---|---|
[Next.js 14 ] StrictMode 해제 하는 방법 (0) | 2024.08.17 |
[Next.js 14 + Supabase ] Supabase 카카오 로그인 구현 (0) | 2024.08.14 |
[Next.js 14 + Supabase ] Supabase auth 로그인 처리 및 6Digit OTP 방식 회원가입 (0) | 2024.08.14 |
[Next.js 14 + Supabase ] Supabase auth로 이메일 인증 처리 및 회원가입 처리하기 (0) | 2024.08.12 |