Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X
Hello There,
i'm trying to write a javascript code inside thingworx from Services tab.
but when i tested the script it gave me this error 'require is not defined'
is there any solution for this issue.
Br,
Mohamed Ewees.
Can you paste the javascript - difficult to under the error message without
I think somehow you are using require() function in your code ,that's why you are getting some reference error .By default require() is not a valid function in client side JS. you need to extend the JS to have the function require() by looking into require.js .
I think i am taking this into right direction ,as you only mentioned the error ,full JS code will be more helpful to check this out .
Thanks
Mukul Narang
Hi Mukul,
thanks a lot for your response.
i'm trying to do something like "var http = require("https"); " but it gave me this error 'require is not defined'.
so , how can i extend the JS to have the function require() by looking into require.js
Thingworx Services are not able to import libraries like in node.js. If you are trying to call a REST or SOAP service, check out the snippets for ContentLoaderFunctions, this will let you do things like GET/POST/PUT requests.