DEV Community

rahulrk867
rahulrk867

Posted on

1 1

SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

        callData: function()

        {

            var urlWAF = myWidget.spaceURL + "/resources/WMSREQRestServiceModeler/getWorkOrderDetails";

            var dataWAF={

                "state": "Active",

            };

            /*var headerWAF={

                "SecurityContext": "ctx::VPLMAdministrator.Company Name.Default"

            };*/

            var methodWAF = "GET";



            WAFData.authenticatedRequest(urlWAF, {

                method: methodWAF, 

                //proxy:'passport',

                data: dataWAF,

                type: 'json',

                onComplete: function (dataResp) {

                    if(dataResp.msg==="OK"){

                        //myWidget.dataFull=JSON.parse(dataResp.data);

                        myWidget.dataFull=dataResp.data;

                        myWidget.displayData(myWidget.dataFull);

                        console.log(myWidget.dataFull);

                    }else{

                        widget.body.innerHTML += "<p>Error in WebService Response</p>";

                        widget.body.innerHTML += "<p>"+JSON.stringify(dataResp)+"</p>";

                    }

                },

                onFailure: function(error){

                    widget.body.innerHTML += "<p>Call Failure</p>";

                    widget.body.innerHTML += "<p>"+JSON.stringify(error)+"</p>";

                }

            });

        },

Image of Stellar post

Check out Episode 1: How a Hackathon Project Became a Web3 Startup 🚀

Ever wondered what it takes to build a web3 startup from scratch? In the Stellar Dev Diaries series, we follow the journey of a team of developers building on the Stellar Network as they go from hackathon win to getting funded and launching on mainnet.

Read more

Top comments (6)

Collapse
 
devdrake0 profile image
Si

You've just posted a code sample, without any explanation of:

1) What have you already tried?
2) The issue is obviously with the code trying to parse dataResp.data, but you haven't provided a snippet of that.

You would find people are far more willing to help if you put a little bit of effort into your question.

Collapse
 
rahulrk867 profile image
rahulrk867

Actually I was trying to get the response data in the custom widgets . but I am facing the error

Collapse
 
rahulrk867 profile image
rahulrk867

I am getting the call failure.

Collapse
 
devdrake0 profile image
Si

Have you tried just logging out the response?

Thread Thread
 
rahulrk867 profile image
rahulrk867

its not working .

const data = ["{woTitle=Accetylene-WO-1, owner=GE Works, woId=34288.53217.59361.13307, objid=34288.53217.59675.21431, name=OXYACE-MB-wo1-000002, taskName=IT0000137, taskAssignmentDate=4\/21\/2020 1:25:09 PM, title=my mb, sorids=[14, 13], taskId=34288.53217.10065.19472, objectType=Measurements, measurementdate=29-Feb-2020}"]

Can you parse this string in json object ??

Thread Thread
 
devdrake0 profile image
Si

That's not valid JSON. Stick it in an online parser and it will probably give you the reasons why.

Jetbrains image

Build Secure, Ship Fast

Discover best practices to secure CI/CD without slowing down your pipeline.

Read more

👋 Kindness is contagious

Please express your appreciation with a heart ❤️ or leave a thoughtful message below if you found this helpful!

Understood!