I'm trying to create a custom class called helpers.js which looks like this:
class Httprequest{
constructor(type, url, username, password,email){
this.type = type;
this.url = url;
this.request = new XMLHttpRequest();
this.username = username;
this.password = password;
this.email = email;
}
static sendPostRequest(){
// function(method,url,async,user,password);
this.request.open(this.type,this.url);
this.request.setRequestHeader('Content-Type' ,'application/x-www-form-urlencoded');
const data = encodeURI('username=' + this.username + '&'+
'password=' + this.password + '&'+
'email=' + this.email);
this.request.send(data);
if(this.request.readyState === 4){
const status = this.request.status;
if(status === 201){
return this.request.status;
}else{
return "Failed creating account"
}
}
}
}
export default Httprequest;
Then I'm trying to import the class in my React Component called Projects.js
import Httprequest from 'helpers.js';
I get error which looks like this: Failed to compile.
./src/components/Projects.js
Module not found: Can't resolve 'helpers.js' in 'C:\Users\Account\Desktop\front\frontend\src\components'
Both files are in the same folder, what gives?