Advertisement
Guest User

Untitled

a guest
Oct 30th, 2022
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //1. --------       WEWNĄTRZ REACTA
  2. useEffect(()=>{
  3.     getOk();
  4.   },[])
  5.  
  6.   let getOk = async ()=>{
  7.         const res = await fetch('/api/test', {
  8.             method: 'GET',
  9.             headers: {
  10.                 'Accept': 'application/json',
  11.             }
  12.         });
  13.  
  14.         const data = await res.json();
  15.         console.log(data);
  16.   }
  17.  
  18. // 2. -------------- WEWNĄTRZ EXPRESSA
  19.  
  20. const express = require('express')
  21. fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));
  22.  
  23. const router = express.Router()
  24.  
  25. router.get('/api/test', async (req, res)=>{
  26.  
  27.     const {access}=req.cookies;
  28.     console.log(access)
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement