hashnode-api
v0.1.1
Published
React functions that help you fetch articles and create articles in hashnode
Downloads
9
Maintainers
Readme
hashnode-api
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.
Live Demo
Install
npm install hashnode-api
Import
For fetching articles from hashnode
import {GetArticles} from "hashnode-api";
Usage
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";
Usage
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 |
Sample Input
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"
};