
A react function created to fetch articles which can be populated in cards for your portfolio.
And also to create posts using their hashnode api.

CodeSandBox
npm install hashnode-api
For fetching articles from hashnode
import {GetArticles} from "hashnode-api";
const {isFetched,data,error} = GetArticles("<USERNAME>",page);
Argument |
Description |
USERNAME : String
|
Your hashnode username |
page : Int
|
The page number that you want to retrieve |
Returns |
Description |
data : object
|
an object having user's information and stories; |
isFetched : boolean
|
true if username is a valid username and data has been fetched; false for all other scenarios |
error : boolean
|
true if username is not valid username and data has been fetched; false if data is fetched |
For creating articles in hashnode
import {CreateArticle} from "hashnode-api";
CreateArticle(input,TOKEN);
Argument |
Description |
input : object
|
Object data required to create story |
TOKEN : string
|
Token string of your account that you can get from developer options in hashnode |
const input = {
title: "New Blog", //Title of your blog
contentMarkdown: `# This is my first Blog`, //Blog content added as markdown
tags: [
{
_id: "56744723958ef13879b9549b",
slug: "testing",
name: "Testing"
}
],//tags that you want to include for your blog
coverImageURL: "https://codybontecou.com/images/header-meta-component.png"
};