Skip to content

Instantly share code, notes, and snippets.

@iam-gopi
Created June 24, 2025 03:08
Show Gist options
  • Select an option

  • Save iam-gopi/a0c60ac7b7dd841039a98bad360ae100 to your computer and use it in GitHub Desktop.

Select an option

Save iam-gopi/a0c60ac7b7dd841039a98bad360ae100 to your computer and use it in GitHub Desktop.
fetch api
async function readData() {
let a = await fetch("https://685a109a9f6ef9611154ea9b.mockapi.io/api/v1");
const r = await a.json();
console.log(r);
}
async function addData() {
const data = {
name: "Gopi",
country: "India",
};
const response = await fetch(
"https://685a109a9f6ef9611154ea9b.mockapi.io/api/v1",
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(data),
}
);
}
addData();
readData();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment