angularjs - Response for preflight has invalid HTTP status code 401 -
i trying post data woocommerce api using angularjs. using oauth library generate signature (i able data successfully).
angular.module('starter.services',[]) .factory('authservice', function($http){ function getdata(urlappended, method, contenttype, data) { ck = 'ck_000'; cs = 'cs_000'; url = 'http://myurl.com/wc-api/v3' + urlappended; oauth = oauth({ consumer: { public: ck, secret: cs }, signature_method: 'hmac-sha1' }); request_data = { url: url, method: method, } params = oauth.authorize(request_data); console.log(params); return $http({ url: request_data.url, method: request_data.method, params: params, data: data, datatype: "json", headers: { "content-type": contenttype } }); } return { getdata: getdata } }) this service have written make requests api. here post request.
authservice.getdata('/customers/', 'post', 'application/json', data).then(function(response){ console.log("done" + response); }) here data json object. error.
xmlhttprequest cannot load http://myurl.com/wc-api/v3/customers/?oauth_consumer_key=ck_eb42…th_signature_method=hmac-sha1&oauth_timestamp=1454961387&oauth_version=1.0. response preflight has invalid http status code 401 here .htaccess code
header add access-control-allow-origin "*" header add access-control-allow-headers "origin, x-requested-with, content-type" header add access-control-allow-methods "put, get, post, delete, options" i have been trying make work cannot it. highly appreciated. thanks.
Comments
Post a Comment