Answers.Body: <pre><code>{% js %}
      let admin_email = "{{ admin_email }}";
      console.log(admin_email);
      alert(admin_email);
  {% endjs %}
  </code></pre>
  
  <p>Missed the <code>""</code> around the assignment. :)</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-16T09:10:10.567Z
Answers.LastActivityDate: 2020-06-16T09:10:10.567Z
Answers.UserDisplayName: Rohan
Body: <p>So I am trying to work with twig templates and I want to inject my project configuration in my js so I can use it.</p>
  
  <p>I can do this</p>
  
  <p><code>{% set admin_email = craft.app.projectConfig.get.email.fromEmail %}</code></p>
  
  <p>And this gives me access to <code>{{ admin_email }}</code> anywhere in the document, just like <code>&lt;?php echo $admin_email ?&gt;</code> would do.</p>
  
  <p>But I want to access these settings inside my JS as well. I have some tokens and other things stored inside there.</p>
  
  <p>I tried doing this:</p>
  
  <pre><code>{% js %}
      let admin_email = {{ admin_email }};
      console.log(admin_email);
      alert(admin_email);
  {% endjs %}
  </code></pre>
  
  <p>But in vain. How do I get the settings inside my JS variables?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-06-16T11:17:18.317Z
Comments.Text: What's the reason you're getting the e-mail from projectConfig and not `craft.systemSettings.email.fromEmail`?
Comments.UserDisplayName: dmatthams
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-06-16T11:19:41.470Z
Comments.Text: It keeps giving me warning that is deprecated. This is the new way of getting it.
Comments.UserDisplayName: Rohan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-06-16T11:22:00.917Z
Comments.Text: That's interesting, did not know that!
Comments.UserDisplayName: dmatthams
Tags: <plugin-development><craft3><php><settings>
Title: How to get my craft projectConfig settings inside JS on the front end
ThreadText: # How to get my craft projectConfig settings inside JS on the front end
  
  (Asked by: username_0 on 2020-06-16)
  
  So I am trying to work with twig templates and I want to inject my project configuration in my js so I can use it.
  
  I can do this
  
  `{% set admin_email = craft.app.projectConfig.get.email.fromEmail %}`
  
  And this gives me access to `{{ admin_email }}` anywhere in the document, just like `<?php echo $admin_email ?>` would do.
  
  But I want to access these settings inside my JS as well. I have some tokens and other things stored inside there.
  
  I tried doing this:
  
  ```
  {% js %}
      let admin_email = {{ admin_email }};
      console.log(admin_email);
      alert(admin_email);
  {% endjs %}
  
  ```
  
  But in vain. How do I get the settings inside my JS variables?
  
  **Tags:** plugin-development, craft3, php, settings
  
  > **Comments:**
  > **username_1**: What's the reason you're getting the e-mail from projectConfig and not `craft.systemSettings.email.fromEmail`?  
  > **username_0**: It keeps giving me warning that is deprecated. This is the new way of getting it.  
  > **username_1**: That's interesting, did not know that!  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2020-06-16. Score: 1 | Accepted answer
  
  ```
  {% js %}
      let admin_email = "{{ admin_email }}";
      console.log(admin_email);
      alert(admin_email);
  {% endjs %}
  
  ```
  
  Missed the `""` around the assignment. :)
  
  
  ---
  
  