I have been trying create module can cant not get rid of this error
Uncaught ReferenceError: require is not defined
I have very little experience with node, so sorry if this has been asked a lot.
getData: function(){
var self = this;
const dataRequest = require('https');
const options = {
"method": "POST",
"hostname": "",
"port": null,
"path": "",
"headers": {
"content-type": "application/json",
"clientsecret": "",
"clientid": "",
"x-rapidapi-key": "",
"x-rapidapi-host": "",
"useQueryString": true
}
};
const req = dataRequest.request(options, function (res) {
const chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
I would use something else but the API I am trying to use shows this as an example, and I am not the best with web calls. I don’t know if this is need but the API returns as json.