XMLHttpRequest cannot load http://localhost:8080/adminUser/login. Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response.
error_handler.js:48 EXCEPTION: Response with status: 0 for URL: null
server has supported CORS...but I still get this.
the code
import {Injectable} from "@angular/core";
import {Http, Headers} from "@angular/http";
import { getUserApi } from "../../../api.config";
@Injectable()
export class UserService {
constructor(public http: Http) {
}
login(userName, password) {
return this.http.post(getUserApi, {userName: userName, password:password})
.map(res => res.json());
}
}
getUserApi
is null or undefined – JensgetUserApi
is not null. because I console.log it – Hu Peng