Context: I'm starting a new project for my company. It's been many years since I've done some web development and decided to build it using the latest platforms (so I'm a still new to all of this).
Current stack:
import {inject} from "aurelia-framework";
import {HttpClient} from "aurelia-http-client";
@inject(HttpClient)
export class Login {
constructor(httpClient){
this.http = httpClient;
}
signIn() {
const url = 'http://localhost:8000/api/user/demo/test';
this.http
.get(url)
.then(data => {
console.log("data");
console.log(data);
})
.catch(error => {
console.log('Error getting ' + url);
console.log(error);
});
};
}
{"status":"success","data":[],"message":"Retrieved ALL users"}
I think that CORS is not allowing you to access localhost:8000
from localhost:9000
. To solve this, you should enable your ExpressJS server to accept CORS requests from localhost:9000
(or all hosts using a wildcard "*").
Look into these resources: