Hi guys!! So sorry to bug you but any of you have ...
# suitecommerce
b
Hi guys!! So sorry to bug you but any of you have had issues when calling the service.ss with the urlRoot path? I am getting Impossible to parse backend error - Request {"url":...}
s
There could be 3 issues. 1. Your service file doesn't exist. 2. You're not returning anything in the response. Like JSON object. 3. The parser is expecting some JSON value but it is getting something else.
b
Hi!! Sohan! Thank you for your response, i am following this: https://developers.suitecommerce.com/develop-your-first-extension.html And my service has this code:
Copy code
/**
* @NApiVersion 2.x
* @NModuleScope Public
*/
define([
    './Example.UserPreferences.Model'
], function (
    ExampleUserPreferencesModel
) {
    'use strict';

    function service (context) {
        var response = {};

        switch (context.request.method) {
            case 'GET':
                response = ExampleUserPreferencesModel.get(context.request)
                break;
        }

        context.response.write(JSON.stringify(response));
    }

    return {
        service: service
    }
})
Backend Model:
Copy code
/**
* @NApiVersion 2.x
* @NModuleScope Public
*/
define([], function () {
    'use strict';

    var ExampleUserPreferencesModel = {
        get: function (request) {
            var data = {
                message: 'This is a message sent from the server!'
            }
            
            return data
        }
    }

    return ExampleUserPreferencesModel
})
Not sure why it is not working.
s
Can you share the response that you get in the front-end ?
b
Impossible to parse backend error - Request {"url":"https://we bsite.com/sca-dev-2022-2-0_ss2/extensions/AFG/Example/1.0.0/Modules/UserPreferences/SuiteScript2/Example.UserPreferences.Service.ss?c=d337623,”type":"GET","isLocal":false,"global":true,"processData":true,"async":true,"contentType":"application/x-www-form-urlencoded; charset=UTF-8","accepts":{"*":"*/*","text":"text/plain","html":"text/html","xml":"application/xml, text/xml","json":"application/json, text/javascript","script":"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},"contents":{"xml":{},"html":{},"json":{},"script":{}},"responseFields":{"xml":"responseXML","text":"responseText","json":"responseJSON"},"converters":{"text html":true},"flatOptions":{"url":true,"context":true},"jsonp":"callback","cache":false,"dataType":"json","parse":true,"emulateHTTP":false,"emulateJSON":false,"dataTypes":["text","json"],"crossDomain":false,"hasContent":false}
s
Not this one. From the network tab.
b
<noscript> <div class="shopping-layout-no-javascript-msg"> <strong>Javascript is disabled on your browser.</strong><br> To view this site, you must enable JavaScript or upgrade to a JavaScript-capable browser. </div> </noscript>
In the preview tab: Javascript is disabled on your browser. To view this site, you must enable JavaScript or upgrade to a JavaScript-capable browser.
s
Is your SS2 SSP library deployed on the domain that you're using?
b
Not sure how the response is not returning since it is in the file (service and backend model)
Ahmmm I do not know
How to know if we have it installed?
b
Is it this one: SuiteCommerce Advanced SS2
👍 1
For some reason the page does not let me scroll down and keeps refreshing.
It was asking for the Name of the User Preferences. 🙂 Thank you guys!