From 6d271fe8e36df46b7efcf31a3695dbcb5fba31bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuzhan=20Bilgin?= Date: Thu, 21 Jul 2022 14:54:47 +0300 Subject: [PATCH] Post One Employee Function --- day-04/promise/postOneEmployeebyOguz.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 day-04/promise/postOneEmployeebyOguz.js diff --git a/day-04/promise/postOneEmployeebyOguz.js b/day-04/promise/postOneEmployeebyOguz.js new file mode 100644 index 0000000..9cf240f --- /dev/null +++ b/day-04/promise/postOneEmployeebyOguz.js @@ -0,0 +1,14 @@ +import fetch from "node-fetch"; + +const url = "http://localhost:8080/api/employees/add"; +const body = { firstName: "Oğuz", lastName: "Bilgin" }; + +const response = await fetch(url, { + method: "POST", + body: JSON.stringify(body), + headers: { + "Content-Type": "application/json", + }, +}).then((resp) => resp.json()); + +console.log(response);