Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

192
Vistas
why my sessionStorage gives { 'object Object': '' }

I have a query I'm passing data from one page to other using local storage. after that i take that data and i make a string . Then i pass that json string to sessionstorage to use as data for my ajax request. but i'm always getting this data as { 'object Object': '' }.

my code ,

const parsedData = JSON.parse(localStorage.getItem('myData'));
    console.log(parsedData,"parsedData");
    
   
 
    parsedData.data.rows.forEach((result, idx) => {
      
     var a = result.master_id;
     var b = result.session_name;
     console.log(a,b,"a","b")

    var userData = {"pid":a,"session" :b};
     console.log( userData ,"userData");  
   
     sessionStorage.setItem('user', JSON.stringify(userData)); 
  
................. then i access this data in another function,
 function graphApi(){
    
     const apiValue = (sessionStorage.getItem('user'));
    
        console.log(apiValue,"apivalue new")
      /*var dat ={
        "pid":"WEB506",
        "session":"WEB506_09092021_M1_S2.csv"
        };*/
       
     
       $.ajax({
        type: "POST",
        data:  apiValue ,   
         url: "http://localhost:5000/file",
        success: function (data) {
          console.log(data)
        },
         error: function(err){
          alert(err);
          }

Plese help, im stuck with for some time now.

in addition, this is my controller api,

File: async (req, res, next) => {
  console.log('---------------');
  console.log( req.body); this is where i get { 'object Object': '' }
  console.log('---------------');
  try{
    if(!req.body){
      throw new Error("sorry no data, error occured")
    }

   const {pid, session} = req.body;
 
   const user = await models.graph_data.findAndCountAll({
    attributes: [
      "document"
    ],
    
   
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You're consoling the whole arrayof objects not a single object try

console.log(data.pid) or console.log(data.session)
about 4 years ago · Juan Pablo Isaza Denunciar

0

Try clearing your sesionStorage and try again. The code

{ 'object Object': '' }  

is a sign that you used a reference value eg JSON object as a key. However, your code doesn't seem to do that. Try clearing your sessionStorage and try again

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda