0

This is what im trying to do.... Both are from my local storage...my "updateProfile" is triggered to "true" when i click on the button to update my form. I tried adding "updateProfile.memberData", but it was not being included when i pass it in my "update" var.

update = {
      JSON.parse(localStorage.getItem('memberData')),
      'updateProfile' = true,
    }

I have to then pass the update to the server:

$http.post(ConfigCnst.restUrl, JSON.stringify(update)).then(function(res)

But i seem to be getting an "Uncaught SyntaxError: Unexpected token ."

3
  • Is there any way where i can pass both into the same variable? Commented Jul 3, 2015 at 4:01
  • Are you sure the string at memberData is valid JSON? Commented Jul 3, 2015 at 4:10
  • I'm not quite sure I understand your question... Do you just need to add one more property to object like this? update = JSON.parse(localStorage.getItem('memberData')); update.updateProfile = true; Commented Jul 3, 2015 at 4:11

2 Answers 2

1

your syntax in building JSON is not correct, try this,

var memberData =   JSON.parse(localStorage.getItem('memberData')) 

then,

update = {memberData:memberData,updateProfile:true }

you can retrieve the update values as below,

 update.memberData
 update.updateProfile 
Sign up to request clarification or add additional context in comments.

1 Comment

Im getting invalid token from my server. Is there a way to make updateProfile into an object aswell?
1

Try this

update = { localdata : JSON.parse(localStorage.getItem('memberData')), updateProfile : true }

1 Comment

Im getting a invalid token from my server reply. It seems to be taking in all the "memberdata" but not the updateProfile.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.