Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

191
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!