I write response using `JSON.stringify()` but if I...
# suitescript
b
I write response using
JSON.stringify()
but if I return html code it adds html comment and it occurs
JSON.parse()
error. This is my SL.
Copy code
response.write({
                        output: JSON.stringify({'message':"<a href='"+csvFile.url+"'>Testing </a>"})
                    });
And this is my client script which parse the response.
Copy code
let response = <http://https.post|https.post>({
            url: scriptUrl,
            body: {},
            headers:{
                'Content-type': 'application/x-www-form-urlencoded'
            }
        });

let body = JSON.parse(response.body);
And we can't parse that json body because of html comment after json. Any help would be appreciated
i
urlencode your csvFile.url variable?
b
It didnt work
Issue is not with url, but html code I think
b
properly set the content type header in the suitelet response
b
@battk I tried both.
application/json
and
application/x-www-form-urlencoded
neither of them did work
b
what did your attempt look like
b
response.setHeader({ name:'Content-type', value:'application/x-www-form-urlencoded' }) before response.write()
b
use the json content type
b
I tried application/json and it didn't work
b
try again