Forum Discussion

JohnHajian's avatar
JohnHajian
Qrew Member
11 months ago
Solved

How can I add my JavaScript app as a CodePage when it uses npm, Restfull API, fetch API, and complex JSON parsing?

I have a JavaScript application which uses npm, Restful API, fetch API, and complex JSON parsing.  When I go to add my application as a CodePage, I get an error.  I have added my application as an attachment. Please help.



------------------------------
John Hajian
------------------------------
  • A code page is designed to be a simple front-end UI. Meaning it can only be accessed by navigating to that url. If that's what you need it could just be a simple html page with your javascript inside a script tag. You would have to remove any instances of require, and instead load those packages in using a cdn script tag inside the header.

    In your case, I suspect you wouldn't really need to load the got package and could just use fetch instead. 

    It also looks like in your case you might just need a script to pull data from a url and push it somewhere else? Pipelines is really good at this stuff using the webhooks channel. You can also use the JSON Handler channel to loop through JSON records. This way you can have it run on a schedule, without a user navigating to the url every time.

    Lastly, if there is a lot of data manipulation between pulling the data and sending it somewhere else, that can sometimes get too complicated for pipelines. And instead you would host it as a script somewhere that can run it on a schedule (i.e. Azure, AWS, Google, Netlify, etc.)



    ------------------------------
    Nathan Allan
    ------------------------------

1 Reply

  • A code page is designed to be a simple front-end UI. Meaning it can only be accessed by navigating to that url. If that's what you need it could just be a simple html page with your javascript inside a script tag. You would have to remove any instances of require, and instead load those packages in using a cdn script tag inside the header.

    In your case, I suspect you wouldn't really need to load the got package and could just use fetch instead. 

    It also looks like in your case you might just need a script to pull data from a url and push it somewhere else? Pipelines is really good at this stuff using the webhooks channel. You can also use the JSON Handler channel to loop through JSON records. This way you can have it run on a schedule, without a user navigating to the url every time.

    Lastly, if there is a lot of data manipulation between pulling the data and sending it somewhere else, that can sometimes get too complicated for pipelines. And instead you would host it as a script somewhere that can run it on a schedule (i.e. Azure, AWS, Google, Netlify, etc.)



    ------------------------------
    Nathan Allan
    ------------------------------