Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions day-04/promise/updateOneEmployee.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* @author M.Emin
*/
import fetch from "node-fetch";

function updateOneEmployee() {
const url = "http://localhost:8080/api/employees/1";
const body = {
firstName: "Adem",
lastName: "Güneş",
};
return fetch(url, {
method: "PUT",
body: JSON.stringify(body),
headers: {
"Content-Type": "application/json",
},

}).then((resp) => resp.json());
}
const result = await updateOneEmployee(); // await promise in çalışmasının bitmesini bekler.
console.log(result);