Skip to content

s47 #1088

Description

@s47213379-glitch

async function createPost() {
try {
const response = await fetch(
"https://jsonplaceholder.typicode.com/posts",
{
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
title: "Learning APIs",
body: "This is my first POST request.",
userId: 1
})
}
);

const data = await response.json();
console.log(data);

} catch (error) {
console.log(error.message);
}
}

createPost();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions