405 Method Not Allowed error with the message: Method not allowed. Must be one of : OPTIONS.

12 views
Skip to first unread message

aku jaya

unread,
Feb 19, 2018, 1:16:05 AM2/19/18
to Angular and AngularJS discussion
IN SERVICE

postBarang(){
  let token = 'XyRXOeeyR3K9llNlcd29b7fa35694265cef23dbcdb52999c15772cf27540b718f1b5c2775c9a57f2jv23Cb6qY0wihSVA5DUQG5826vxZUAMoFIqfvQHyv3n+srp2kJQqabZgyMEjGG6DzVwB4RGYJm4INNSx';
  let httpOptions = {
      headers: new HttpHeaders({
        'Content-Type':  'application/json',
        'Authorization' : token
      })
    };
  console.log(httpOptions);
  let bodyBarang = {
  "page" : "1", 
  "tipe" : "ready", 
  "valuecat" : "1"
  }
  return this.http.post(url,bodyBarang, httpOptions)
  .map((res: Response)=>res.json())
  }


IN COMPONENTS

ngOnInit() {

    this.homeSrv.postBarang()
      .subscribe(res=>{
        console.log(res)
      })
}

Sander Elias

unread,
Feb 19, 2018, 7:13:10 AM2/19/18
to Angular and AngularJS discussion
Hi Aku,

I think you have a CORS issue on your server.

Regards
Sander
Reply all
Reply to author
Forward
0 new messages