amazon web services - Angular and API Gateway: how to implement the PUT method? -
i'm developing web application angular 4 using typescript language (frontend side) , aws api gateway (backend side). have problem: api gateway configured data update put request works perfectly. if use code in application (correcturl
string refers correct url)
putobject(myobject: myobject) { if (this.authservice.getauthtoken()) { let cognitotoken = this.authservice.getauthtoken(); let headers = new headers({'content-type': 'application/json'}); headers.append('authorization', cognitotoken); //jwt token let url = correcturl; return this.http.put(url, json.stringify(myobject) , {headers}) .map(data => data.json()) .catch(this.handleerror); } else { let errmsg = 'error retrieving authrization token cognito user session'; console.error('error message: ' + errmsg); return observable.throw(errmsg); } }
if invoke method (which seems correctly written), put request not executed (although json object matches perfectly) , appears on consoles: method put not allowed access-control-allow-methods in preflight response.
strange, because if go "enable cors", there checkboxes in 3 methods: put, get, options (just because put has check mark, don't understand error this. invoking request in same way , works perfectly, don't explain because not happen same put!
Comments
Post a Comment