File size: 513 Bytes
bcb0b63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
const CREATE_PIN_URL = "https://jsonplaceholder.typicode.com/posts";
const app = document.querySelector("#app");

app.addEventListener("submit", async (e) => {
 e.preventDefault();
 try {
    const response = await fetch(CREATE_PIN_URL, {
      method: "POST",
      body: JSON.stringify({
        title: document.querySelector("#title").value,
        description: document.querySelector("#description").value,
      }),
    });
    console.log(response.json());
 } catch (error) {
    console.log(error);
 }
});