0.3.0 • Published 4 months ago

@jay-es/jsonplaceholder-client v0.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

JSONPlaceholder client

CI NPM npm (scoped with tag) code style: prettier types: TypeScript

Fully typed client of the JSONPlaceholder API for TypeScript/JavaScript.

Install

$ npm install @jay-es/jsonplaceholder-client

Features

// Getting a resource
const post = await getPost(1);

// Listing all resources
const allPosts = await getPosts();

// Filtering resources
const user1Posts = await getPosts({ userId: 1 });

// Creating a resource
await createPost({ userId: 7, title: "Foo", body: "Lorem ipsum" });

// Updating a resource
await updatePost(1, { id: 1, userId: 7, title: "Foo", body: "Lorem ipsum" });

// Patching a resource
await patchPost(1, { title: "Foo" });

// Deleting a resource
await deletePost(1);

Resources

postcommentalbumphototodouser
getPostsgetCommentsgetAlbumsgetPhotosgetTodosgetUsers
getPostgetCommentgetAlbumgetPhotogetTodogetUser
createPostcreateCommentcreateAlbumcreatePhotocreateTodocreateUser
updatePostupdateCommentupdateAlbumupdatePhotoupdateTodoupdateUser
patchPostpatchCommentpatchAlbumpatchPhotopatchTodopatchUser
deletePostdeleteCommentdeleteAlbumdeletePhotodeleteTododeleteUser

Listing nested resources

e.g. https://jsonplaceholder.typicode.com/posts/1/comments

const comments = await getPostComments(1);
const photos = await getAlbumPhotos(1);
const albums = await getUserAlbums(1);
const todos = await getUserTodos(1);
const posts = await getUserPosts(1);
0.3.0

4 months ago

0.2.0

11 months ago

0.1.0

12 months ago