@jay-es/jsonplaceholder-client
TypeScript icon, indicating that this package has built-in type declarations

0.3.0 • Public • Published

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

post comment album photo todo user
getPosts getComments getAlbums getPhotos getTodos getUsers
getPost getComment getAlbum getPhoto getTodo getUser
createPost createComment createAlbum createPhoto createTodo createUser
updatePost updateComment updateAlbum updatePhoto updateTodo updateUser
patchPost patchComment patchAlbum patchPhoto patchTodo patchUser
deletePost deleteComment deleteAlbum deletePhoto deleteTodo deleteUser

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);

Package Sidebar

Install

npm i @jay-es/jsonplaceholder-client

Weekly Downloads

2

Version

0.3.0

License

MIT

Unpacked Size

15.8 kB

Total Files

5

Last publish

Collaborators

  • jay-es