surveyjs / surveyjs_react_quickstart

SurveyJS + React Quickstart Template
http://surveyjs.io
140 stars 78 forks source link

console.log(result) is returning [Object Object] in onComplete function #8

Closed CedricHadjian closed 5 years ago

CedricHadjian commented 5 years ago

And doing console.log(JSON.stringify(result)) is returning the JSON form itself! I am using it with react, it's the same for this repo: https://github.com/surveyjs/surveyjs_react_quickstart

So, how am I gonna see the results? Thanks in advance

dmitry-kurmanov commented 5 years ago

@CedricHadjian hello! If I understand you correctly, this is how console.log works. You can try console.dir to see an object.

Also you can reproduce the problem in the plunker (https://plnkr.co/edit/fl3REIgSXefKvy78xchI?p=preview) and post it here.

CedricHadjian commented 5 years ago

@CedricHadjian hello! If I understand you correctly, this is how console.log works. You can try console.dir to see an object.

Also you can reproduce the problem in the plunker (https://plnkr.co/edit/fl3REIgSXefKvy78xchI?p=preview) and post it here.

I know how console.log() works, I'm expecting to see the survey's result in console.log(JSON.stringify(result)) but it's returning the JSON file I created with some missing objects (no idea why) Shouldn't it show the chosen options from the survey the user has chosen?

CedricHadjian commented 5 years ago

I.e: console.log(JSON.stringify(result)); returns this: {"pages":[{"name":"page1","elements":[{"type":"bootstrapslider","name":"1","title":"Amount to invest","step":1000,"rangeMax":150000}]},{"name":"page2","elements":[{"type":"radiogroup","name":"2","title":"What is your investment horizon?","choices":["Less than 1 year","1 to 3 years","3 to 5 years","5 to 10 years"]}]},{"name":"page3","elements":[{"type":"radiogroup","name":"3","title":"What type of Debt do you have?","choices":["Credit Card","Line of Credit","Auto","Student Loans"]}]}],"showQuestionNumbers":"off","goNextPageAutomatic":true}

and my JSON that I'm passing to the survey looks like this: {"showPageNumbers":"false","showQuestionNumbers":"off","goNextPageAutomatic":true,"pages":[{"questions":[{"type":"bootstrapslider","name":"1","title":"Amount to invest","step":1000,"rangeMin":0,"rangeMax":150000}]},{"questions":[{"type":"radiogroup","name":"2","title":"What is your investment horizon?","choices":["Less than 1 year","1 to 3 years","3 to 5 years","5 to 10 years"]}]},{"questions":[{"type":"radiogroup","name":"3","title":"What type of Debt do you have?","choices":["Credit Card","Line of Credit","Auto","Student Loans"]}]}]}

CedricHadjian commented 5 years ago

I'm expecting "console.log(JSON.stringify(result)) to return just like what it returns in the website: Example: {"langs":["Java"]}

dmitry-kurmanov commented 5 years ago

@CedricHadjian could you please check the plunker example above and the doc https://surveyjs.io/Documentation/Library/?id=surveymodel#onComplete . I think you just need to use the following code: console.log(result.data)

CedricHadjian commented 5 years ago

@CedricHadjian could you please check the plunker example above and the doc https://surveyjs.io/Documentation/Library/?id=surveymodel#onComplete . I think you just need to use the following code: console.log(result.data)

PERFECT, thank you!! I've been trying stuff since yesterday and nothing worked. console.log(result.data) did it.