As the external .js file url belongs to the customer, so I can't share that, I need to include the external js file, and call the function from that external js file. I have seen some solution like:
const script = document.createElement('script');
script.src = url; //(This is external js url)
script.async = true;
document.body.appendChild(script);
But it is not working for me, or may be I don't know how it works
Assume this is the external sample code:
Sample code to call locally, if we manually download the file and import
let conn = demo("url", false)
conn.login("username", "myPassword")
How to do same above call after including in the reactjs
export default function demo (end, sec) {
const login = (user, password) => {
console.log(" sending login message")
}
const logout = async (user) => {
console.log(" sending logout message")
}
/*
* Expose these methods to the client
*/
return { login, logout }
}