How to get Require.js to fetch a script that doesn't end with `.js`?

I am developing an application that uses a specific site to facilitate payments, and the method of processing payments requires importing some javascript from this url https://bridge.paymill.com/ , which contains the script.

The fact is that I use js to load all the scripts, in my main.js configuration, I try to do this as follows:

 requirejs.config({ ... 'paymill': 'https://bridge.paymill.com/', ... }); 

But this, of course, is trying to extract from https://bridge.paymill.com/.js , which is not a valid URL (it is without the last .js)

How can I notify requirejs to download this without adding ".js" at the end?

+6
source share
1 answer

Put a question mark at the end of the URL

 requirejs.config({ ... 'paymill': 'https://bridge.paymill.com/?', ... }); 

How it works:

https://bridge.paymill.com/?.js is a valid URL with .js as a GET request.

+8
source

Source: https://habr.com/ru/post/958494/


All Articles