Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to include an external javascript file into project?

ANSWERED

So I have an API I want to consume in my app and it is a regular minified javascript file.  How can I include this in my application?  Would I need to convert it to a ES6 module in real time each time the app is loaded?  In examples of consuming API's none of the examples included an external javascript file that i can see and I'm wondering how this is done.

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

You can import JS code external to the file you are working on using ES6 modules (e.g. import { exports } from './module-path') if that's what you are looking to do? You would only have to export what you needed from the external file using the ES module export syntax.

 

It might be easier to work with the un-minfied code to do this if there are only a few things you need to export but the Fitbit SDK will minify your code during the build process.

 

View best answer in original post

Best Answer
2 REPLIES 2

Do I need to use file transfer to import it?

Best Answer
0 Votes

You can import JS code external to the file you are working on using ES6 modules (e.g. import { exports } from './module-path') if that's what you are looking to do? You would only have to export what you needed from the external file using the ES module export syntax.

 

It might be easier to work with the un-minfied code to do this if there are only a few things you need to export but the Fitbit SDK will minify your code during the build process.

 

Best Answer