0

I am trying to use functions in dcsubscriber.js:

enter image description here

However, when running the website, the content of dcsubscriber.js is replaced completely by some odd html code:

enter image description here


Update:

I use Admin panel to add html code from Markdown editor

enter image description here

Franva
  • 6,565
  • 23
  • 79
  • 144

1 Answers1

0

You can use react-helmet
Put your js file inside static folder and use them like this :

<Helmet>
  <script crossorigin="anonymous" src="/test.js" />
</Helmet>
  • Hi, I am using React-Helmet, that is where I load the separated dcsubscriber.js file which contains the updateSubscription() method. – Franva Aug 31 '20 at 10:35
  • so just need to put your js file inside static folder – Aurelio LIMA FERREIRA Aug 31 '20 at 10:41
  • yep, this is where I put the dcsubscriber.js right now, but once I put it under the static folder, then I am not able to access to process.env.. – Franva Aug 31 '20 at 11:03
  • hi @Aurelio, to see more details about no access to environmental variables,please have a look at this question: https://stackoverflow.com/questions/63611042/how-to-use-environmental-or-os-variables-in-self-created-javascript-files thanks – Franva Aug 31 '20 at 23:22
  • need to check if you can use netlify lambda function (/.netlify/functions/hello) with your script – Aurelio LIMA FERREIRA Sep 01 '20 at 09:50
  • 1
    yep, I can confirm that I can use the lambda function from the dcsubscriber.js. The lambda function is hosted separately so anyone can call it anyway. – Franva Sep 01 '20 at 11:53