javascript - Clear LocalStorage from server-side -
hello need clear() localstorage server-side.
the right moment after inserting info in db (info took localstorage) , need redirect , clear localstorage..
i tried node-localstorage can't controller...
edit:
im working on node.js javascript server side..
part of code:
var mpa = require('../models/mpedidosabastecimiento'); var mysql = require('mysql'); var async = require('async'); var localstorage = require('node-localstorage').localstorage, localstorage = new localstorage('./scratch'); function postalta(req, res){ params = req.body; var objdatos = params.objdatos; var objdatosparsed = ""; tipo_de_objdatos = typeof objdatos; if (tipo_de_objdatos == "string"){ objdatosparsed = json.parse(objdatos); }else if (tipo_de_objdatos == "object"){ stringiii = json.stringify(objdatos); objdatosparsed = json.parse(stringiii); } else { console.log("no es ni string ni object, es: "+tipo_de_objdatos); } var aart = objdatosparsed.aarticulos; var fecha_generacion = params.fecha_generacion; var id_sector = params.sector; var connection = mysql.createconnection({ user: 'xxx', password: 'xxx', host: 'xxx.xxx.xxx.xxx', port: 'xxx', database: 'xxx', datestrings : xxx }); connection.connect(); mpa.getlastnropa(function (ultimo_nro_pa){ ultimo_nro_pa = ultimo_nro_pa[0].nro_pa; var nro_pa = 1; if (ultimo_nro_pa != 0) nro_pa = ultimo_nro_pa+1; fecha_generacion = changedate(fecha_generacion); async.eachseries(aart, function (articulo, callback) { var id_articulo = articulo.id_articulo_fk; var id_responsable = articulo.id_responsable_fk; var id_centro_costo = articulo.id_centrocosto_fk; var fecha_necesidad = articulo.fecha_necesidad; var urgente = articulo.urgente; var cantidad = articulo.cantidad; fecha_necesidad = changedate(fecha_necesidad); var query= "insert pedidos_abastecimiento(nro_pa, fecha_gen, id_centrocosto_fk, id_responsable_fk, fecha_necesidad, " +"id_articulo_fk, cantidad, urgente, id_sector_fk) "+ "values("+nro_pa+", '"+fecha_generacion+"', "+id_centro_costo+", "+id_responsable+", '"+fecha_necesidad+"', " +id_articulo+", "+cantidad+", "+urgente+", "+id_sector+")" connection.query(query, function (err, rows, fields) { if (err){ throw err; console.log(err) }else{ console.log("no errors in query."); console.log(query); callback(); } }); }, function (err) { //here nee clear localstorage 'paalta' can render without data listed localstorage.clear(); connection.end(); res.redirect('paalta'); }); }); }
just clean value
localstorage.setitem("yourkey","");
or
localstorage.setitem("yourkey",null);
Comments
Post a Comment