0.0.1-security • Published 3 years ago
fetch-xd v0.0.1-security
Handle data with fetch method
You can see more example at this
import { get, post, put, del } from 'fetch-xd';
// Get method
// type
type TPerson = {
userId: number;
id: number;
body: string;
title: string;
};
get<TPerson[]>("https://jsonplaceholder.typicode.com/posts").then(
({ data }) => {
console.log(data);
}
);
// Post
const { data } = await post<{ id: number }>(
"https://jsonplaceholder.typicode.com/posts",
{ title: "my post", body: "some content" }
);
Other methods are similar
Author: Nguyen Dung