I have this code:
client (angular2) hosted on this url:
http://localhost:8080/Me/html/pages/gasolina/country/USA
code:
return this.http
.post(this.supporToolSaveUrl, gasConfigModel, {headers: headers})
.map(res => res.json())
.subscribe(
data => {
console.info("next: ");
console.info(data)
},
err => console.error(err)
);
server (java jersey)
hosted on this url:
http://localhost:8080/Me/services/SaveConfig
code:
@Path("/SaveConfig")
@POST
@Consumes(MediaType.APPLICATION_JSON + ";charset=utf-8")
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public void saveConfig(CountryGasStationConfig countryGasStationConfig) throws Exception {
should i add these in jersy annotation?
When i run locally i get this error:
MLHttpRequest cannot load http://locahost:8080/.... Response for preflight is invalid (redirect)
I saw this post and this post
How can i make this solution in angular2?
app.
config(['$httpProvider', function ($httpProvider) {
//Reset headers to avoid OPTIONS request (aka preflight)
$httpProvider.defaults.headers.common = {};
$httpProvider.defaults.headers.post = {};
$httpProvider.defaults.headers.put = {};
$httpProvider.defaults.headers.patch = {};
}]);