cookie-json-converter
v1.0.2
Published
Simple cookie to json converter
Downloads
43
Maintainers
Readme
Simple express cookie to json converter
Setup
CommonJS
const express = require("express");
const { scv } = require("cookie-json-converter");
var app = express();
app.listen(/*...*/);
EsModule
import express, { Request, Response } from "express";
import { scv } from "cookie-json-converter";
var app = express();
app.listen(/*...*/);
Examples
CommonJS
app.get("setCookie",function(req,res){
res.cookie(/*"cookie name"*/,/*"cookie value"*/,/*"options"*/).send("cookies setted")
})
app.get("/getCookies",function (req,res){
console.log(scv(req))//returns {"coookie name":"cookievalue"}
res.send("check the console")
})
app.cookie("/getCookie",function (req,res){
console.log(scv(req)[/*cookie name*/])//returns "cookievalue" of "cookie name"
res.send("check the console")
})
EsModule
app.get("setCookie",function(req:Request,res:Response){
res.cookie(/*"cookie name"*/,/*"cookie value"*/,/*"options"*/).send("cookies setted")
})
app.get("/getCookies",function (req:Request,res:Response){
console.log(scv(req))//returns {"coookie name":"cookievalue"}
res.send("check the console")
})
app.cookie("/getCookie",function (req:Request,res:Response){
console.log(scv(req)[/*cookie name*/])//returns "cookievalue" of "cookie name"
res.send("check the console")
})