Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const showName = () => {
- let userInput = document.getElementById("inpt").value;
- fetch(`https://jsonplaceholder.typicode.com/users/${userInput}`)
- .then((res) => res.json())
- .then((data) =>{
- console.log(data.name);
- document.getElementById("details").innerHTML = data.name
- }).catch((err)=>{
- console.log(err);
- })
- }
- const sendData = () =>{
- const name = document.getElementById("name").value;
- const age = document.getElementById("age").value;
- const id = document.getElementById("id").value;
- fetch("/sendData",{
- method:"POST",
- headers: {
- "Content-Type": "application/json"
- },
- body:JSON.stringify({
- name,age,id
- })
- }).then( res => res.json()).then(data => {console.log(data);})
- }
- const removeUnder18 = () =>{
- fetch("/removeUnder18",{
- method: "DELETE",
- headers:{
- "Content-Type": "application/json"
- }
- }).then(res=>res.json()).then(data => console.log(data)).catch((err)=>{
- console.log(err);
- })
- }
- const sendAndAlert = () => {
- const userName = document.querySelector('#userName').value;
- const age = document.querySelector('#ageOf').value;
- fetch("/alertDetails",{
- method: "POST",
- headers:{
- "Content-Type": "application/json"
- },
- body:JSON.stringify({
- name:userName,
- age:age
- })
- }).then( res => res.json()).then(data =>{
- alert(data.message)
- })
- }
- let object = {name: "Etian",Price: 50}
- localStorage.setItem('myUser',object)
- // I would appreciate feedback and opinions
- // Steam: CheezPuff
- // Discord: CheezPuff#7720
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement