“Reacione o cookie” Respostas de código

Reacto Definir cookie

import Cookies from 'universal-cookie';
const cookies = new Cookies();
cookies.set('myCat', 'Pacman', { path: '/' });
console.log(cookies.get('myCat')); // Pacman
Abdullah Al Muzaki

Defina cookie em reactjs

npm install react-cookie
        or 
yarn add react-cookie

import { useCookies } from 'react-cookie'

const SignInComponent = () => {


const [cookies, setCookie] = useCookies(['access_token', 'refresh_token'])

async function onSubmit(values) {
    const response = await getOauthResponse(values);

    let expires = new Date()
    expires.setTime(expires.getTime() + (response.data.expires_in * 1000))
    setCookie('access_token', response.data.access_token, { path: '/',  expires})
    setCookie('refresh_token', response.data.refresh_token, {path: '/', expires})


}


}
30_Savaliya Denish

Reacione o cookie

// server.jsrequire('@babel/register'); const express = require('express');const serverMiddleware = require('./src/server').default;const cookiesMiddleware = require('universal-cookie-express'); const app = express(); app  .use('/assets', express.static('dist'))  .use(cookiesMiddleware())  .use(serverMiddleware); app.listen(8080, function() {  console.log('Listening on 8080...');});
Fantastic Fowl

Respostas semelhantes a “Reacione o cookie”

Perguntas semelhantes a “Reacione o cookie”

Procure respostas de código populares por idioma

Procurar outros idiomas de código