I am currently developing in Next.js and React (TypeScript).
Then a problem arose.
It is the inability to load js files.
I have tried the following.
・Import javascript modules
import * as module from '../../../script';
・require code
const remise = require('../../../script/rtoken-3.0.0');
Neither did it work.
Please tell me how to write it. Thank You.
Here is the code. ・js(path:../../../script/rtoken-3.0.0.min.js)
(function (window, undefined) {
var CONNECTION_TIMEOUT = 5000;
function rtoken() {
this.consumerID = '';
this.SessionTimeout = 60000;
this.ConnectionAddress = '';
~
var rtoken = this;
window.onbeforeunload = function () {
rtoken.Abort();
};
window.onpagehide = function () {
rtoken.Abort();
};
}
rtoken.prototype = {
Init: function () {
this.consumerID = getUUID();
this.SessionTimeout = 60000;
this.TokenType = '';
~
},
Create: function () {
var self = this;
requestData = "{\"SessionID\":\"" + this.consumerID + "\"," + "\"TokenType\":\"" + this.TokenType + "\"," + "\"Sequence\":\"" + this.Sequence + "\"," + "\"Options\":\"" + this.Options + "\"}";
exJsonp(self.ConnectionAddress, CONNECTION_TIMEOUT, requestData, "CreateToken", function (data) {
~
});
},
};
function exJsonp(url, htttimeout, RequestData, MethodName, Callback) {
try {
$.ajax({
url: url,
type: 'POST',
dataType: 'jsonp',
data: encodeURIComponent(RequestData),
jsonpCallback: MethodName,
timeout: htttimeout,
success: function (data) {
Callback(data);
},
error: function (data) {
Callback(data);
},
complete: function (data) {}
});
} catch (e) {
Callback(null);
}
};
function getUUID() {
var uuid, i, random;
uuid = "";
for (i = 0; i < 32; i++) {
~
}
return uuid;
};
if (!window.remise) {
window.remise = {};
}
window.remise.rtoken = rtoken;
})(window);
tsfile()
~
import * as rtoken from '../../../script/rtoken-3.0.0.min'; // ×
export const Index = (props) => {
const jsModule = require('../../../script/rtoken-3.0.0');
var token= jsModule();
// What does not come in to token
console.log('token:', token);
return (
null
)
}