javascript - angular single $http request, node shows two requests -
Showing two requests on a single request node in angular, undefined in the form of an X-at-token and another token with.
I finally saw the result of errors in the node in my corner frontend (attached screenshots).
angular code:
var itself = this; Var $ http = angular.injector (["ng"]) Obtain ("$ http"); Var authToken = localStorage.getItem ("authToken")? LocalStorage.getItem ("authToken"): config.authToken; $ Http.defaults.headers.common ["X-Auth-Token"] = authToken; $ Http.get (Config.url) .success (function (data, position, header, config) {self.onResult (data);}). Terror (function (data, position, header, config) {console.log (data); // This is empty console.log (condition); // stauts is 0 console.log (header); console.log (config) ; Self.onFault (data);});
node. Js
var self = this; App Use (function (request, response, next) {response ("X-power-to-A", "FIC"); response title ("access-control-permission-original-origin", "*"); Response .header ("access-control-permission-header", "origin, with X-requested, content-type, accept, x-right-token"); request.id = self.id ++; console.log (Request id, request.url, request.headers ['x-auth-token']); Next ();});
Node console output
0 '/attendees?appId=ag.casa.fico' undefined1 '/attendees?appId=ag.casa.fico '' eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlbWFpbEFkZHJlc3MiOiJjcmlzdGlhbi5yYWN1QGJpcm91bGRlY3JlZGl0LnJvIiwicGFzc3dvcmQiOiIxMDU3In0.X7rztUCDRngXLV6ZABvv7hqwzvWEJi1Nulxg4KWL -58 '
If you try to put all your settings Is in an object and then $ http request
var req = {method: 'POST', url: 'http://example.com', under headers: {' Content-type ': undefined}, data: {test:' test '},} $ http (req) .success (function () {...}). Error (function () {...});
See here $ http #settings- http-headers
Comments
Post a Comment