How do you import a javascript package from a cdn script tag in React

0 votes

I'd like to import this javascript package in React

<script src="https://cdn.dwolla.com/1/dwolla.js"></script>

However, there is no NPM package, so I can't import it as such:

import dwolla from 'dwolla'

or

import dwolla from 'https://cdn.dwolla.com/1/dwolla.js'

so whenver I try

dwolla.configure(...)

I get an error saying that dwolla is undefined. How do I solve this?

Thanks

Jun 4, 2020 in Angular by kartik
• 37,520 points
25,141 views

1 answer to this question.

0 votes

Hello,

Go to the index.html file and import the script

<script src="https://cdn.dwolla.com/1/dwolla.js"></script>

Then, in the file where dwolla is being imported, set it to a variable

const dwolla = window.dwolla;

Hope it works!

To know more about javascript packages, join our Java course session now.

answered Jun 4, 2020 by Niroj
• 82,840 points

Related Questions In Angular

0 votes
1 answer

How can I strip HTML tags from a string in ASP.NET?

Hello @Kartik, If it is just stripping all HTML tags ...READ MORE

answered Jul 23, 2020 in Angular by Niroj
• 82,840 points
1,835 views
0 votes
1 answer

How to pass data from a child component to a parent component in Angular 4?

In Angular 4, passing data from a ...READ MORE

answered Dec 4 in Angular by Navya
62 views
0 votes
1 answer

How do you handle uncaught exceptions and promise rejections in Express.js?

Handling uncaught exceptions and unhandled promise rejections ...READ MORE

answered Dec 6 in Angular by Navya
25 views
0 votes
0 answers
0 votes
1 answer

From php returning JSON to JavaScript

Hii @kartik, You can use Simple JSON for PHP. ...READ MORE

answered Jun 5, 2020 in Java-Script by Niroj
• 82,840 points
1,062 views
0 votes
1 answer

How do I conditionally add attributes to React components?

Hello @kartik, For certain attributes, React is intelligent ...READ MORE

answered Jul 22, 2020 in Angular by Niroj
• 82,840 points
8,824 views
0 votes
2 answers

Error: EACCES: permission denied, access '/usr/local/lib/node_modules' react

Hello @kartik, Change your file permissions like this First ...READ MORE

answered Jul 22, 2020 in Angular by Niroj
• 82,840 points
23,171 views
0 votes
1 answer

How to specify a port to run a create-react-app based project?

Hello @kartik, You could use cross-env to set the port, ...READ MORE

answered Jul 22, 2020 in Angular by Niroj
• 82,840 points
5,938 views
0 votes
1 answer

How do I include a JavaScript script file in Angular and call a function from that script?

Hello @kartik, Refer the scripts inside the angular-cli.json (angular.json when using ...READ MORE

answered Sep 8, 2020 in Angular by Niroj
• 82,840 points
14,183 views
0 votes
1 answer

How do you bind an Enum to a DropDownList control in ASP.NET?

Hello @kartik, I probably wouldn't bind the data as it's ...READ MORE

answered Jul 23, 2020 in Angular by Niroj
• 82,840 points
3,022 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP