-
Notifications
You must be signed in to change notification settings - Fork 0
Data
This React hook fetches comments from a placeholder JSON file (./placeholder.json). It then sorts the filtered comments in descending chronological order (newest first).
Returns: An array of posts in descending cronological order
This React hook fetches posts from a placeholder JSON file (./placeholder.json) and filters them based on the provided id. It returns the first matching post or undefined if no post is found.
Parameters:
id (string): The unique identifier of the post to retrieve.
Returns:
Object | undefined:
An object representing the matching post if found.
undefined if no post matches the provided id.
Usage:
This React hook fetches user data from a placeholder JSON file (./placeholder.json).
Returns: Object: An object representing the user data from the JSON file.
This React hook fetches comments from a placeholder JSON file (./placeholder.json) and filters them based on the provided blog post id. It then sorts the filtered comments in descending chronological order (newest first).
Parameters:
postId (number): The unique identifier of the post for which to retrieve comments.
Returns: Array<Object>: An array of comment objects matching the specified id, sorted by date (newest first). If no comments match the id, an empty array is returned.
{
title: string
content: string
author: string (name for now, maybe we will use an ID later)
date: string (ISO format)
id: string
likes: number
}
{
name: string
}
{
"post": "c6d5e4f3",
"author": "DavidLee",
"likes": 14,
"id": "u8v9w0x1",
"date": "2023-04-22T16:15:00.000Z",
"content": "Thanks for answering my questions!"
}
(I don't really know how to document data schema, so if anyone knows a better way, please change it)