0

i am passing url dynamically in following code which is producing error "SyntaxError: Unexpected token ':'because url is dynamically added as https://wizkidtest.daily.co/testcall but when i harcode url as 'https://wizkidtest.daily.co/testcall' it works fine, adding url in string '' makes the difference

let script = this._renderer2.createElement("script");
    script.type = `text/javascript`;
    script.text = `
        {
          callFrame = window.DailyIframe.createFrame({
        showLeaveButton: true,
        iframeStyle: {
          position: 'fixed',
          width: '100%',
          height: '100%'
        }
      });
          callFrame.join({ url: ${this.url} })
        }
    `;
    this._renderer2.appendChild(this._document.body, script);
6
  • you can use directly {url:this.url} -you use the sintax ${expresion}, I think that is `${...}`, enclosed by ` Commented Jul 9, 2021 at 7:34
  • script.text is already in ... Commented Jul 9, 2021 at 7:38
  • Sorry, I read so quick, try console.log(this.url,script.text) to see what is the value ofthis.url Commented Jul 9, 2021 at 7:41
  • wizkidtest.daily.co/ftgRz6okB76OismZAjBF { callFrame = window.DailyIframe.createFrame({ showLeaveButton: true, iframeStyle: { position: 'fixed', width: '100%', height: '100%' } }); callFrame.join({ url: wizkidtest.daily.co/ftgRz6okB76OismZAjBF }) } Commented Jul 9, 2021 at 7:44
  • I think forget the quotes, but I'm not sure callFrame.join({ url: "${this.url}" }) Commented Jul 9, 2021 at 7:47

1 Answer 1

4

Since you're passing whole script as string, you need to ensure that your url is wrapped in quotation marks within that script - otherwise it won't be treated as a string, e.g.

callFrame.join({ url: "${this.url}" })

or

callFrame.join({ url: '${this.url}' })

Without that, it would create an output of { url: https://wizkidtest.daily.co/testcall } which is wrong.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.