+ Start a Discussion
Leo10Leo10 

How to use turf.js in salesforce lightning component?

Hi all
I want to use turf.js in salesforce lightning component. While  I am including turf.js in salesforce lightning component getting an error like "ReferenceError: jsts is not defined" but it is working fine in visual force page. Can any one tell how to include turf.js in lightning components
Thank you,
Pramodh KumarPramodh Kumar
usually in lightning if you want to include the static resoure you have to use 

<ltng:require tag

if your static source is part of zip file then you have to use like below code
<ltng:require 

        styles="{!$Resource.SLDSv1 + '/assets/styles/lightning-design-system-ltng.css'}"

        scripts="{!$Resource.jsLibraries + '/jsLibOne.js'}"

        afterScriptsLoaded="{!c.scriptsLoaded}" />

just js file then you have use like
<ltng:require scripts="{!$Resource.Query}" afterScriptsLoaded="{!c.afterScriptsLoaded}"/>

Let me know if you have any questions


Pramodh
Leo10Leo10
Hi, 
Now, we are not using.
<ltng:require scripts="{!$Resource.Query}" afterScriptsLoaded="{!c.afterScriptsLoaded}"/>

But using like 
<ltng:require scripts=" /resource/Query" afterScriptsLoaded="{!c.jsLoaded}"/>

I know how to include js file. But I can't able to include 'turf.js' file. I am getting an error.
I have included the same in the visualforce page.

Thank you.

 
Pramodh KumarPramodh Kumar
may i know what is the error message you are getting
Leo10Leo10
Refused to connect to 'https://act.my.salesforce.com/c/turf' because it violates the following Content Security Policy directive: "connect-src 'self' https://api.bluetail.salesforce.com https://staging.bluetail.salesforce.com https://preprod.bluetail.salesforce.com *.eu11.visual.force.com".
 
Mark A LoweMark A Lowe
Hi Leo10, have you had any luck with this out of interest? Did you try add Turf.js in as a CSP Trusted Site? https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/csp_trusted_sites.htm