Skip to main content

Posts

Showing posts from November, 2021

GET request kaj kortese

 React code  import ' ./App.css '; import { useState , useEffect } from ' react '; import Todos from ' ./Components/Todos '; function App () {   const [ todo , setTodo ] = useState ([]);   const conn = () => {     console . log (' h ')     // fetch('https://jsonplaceholder.typicode.com/users')     fetch (" http://localhost:5000/about ", {       headers : {         ' Content-Type ': ' application/json ',         ' Accept ': ' application/json '        }     })     . then ( response => response . json ())     . then ( json => console . log ( json ))     . catch (( err ) => console . log ( err ));   }   // useEffect(() => {   //   fetch('https://jsonplaceholder.typicode.com/users')   //   .then(response => response.json())   //   .then(json => setTodo(js...

Fetch post

 React App.js file  import ' ./App.css '; import Form from ' ./components/Form '; import Header from ' ./components/Header '; import Fetch from ' ./components/Fetch '; import { useEffect , useState } from ' react '; function App () {   const [ count , setCount ] = useState ([]);   const handleAddProduct = () => {     fetch (' http://localhost:5000/p ',{       method:" POST ",       headers:{         ' Content-Type ':' application/json '       },       body: JSON . stringify ({' name ':' Rifat '})     })   }   return (     <>     < div >      < button onClick = { handleAddProduct }>Click</ button >     </ div >         </>   ); } export default App ; Nodejs app.js file const express = require (' express '); const app = express (); ...