Error: SyntaxError: DOM Exception 12 …

Orange project Chrome is running normally, Safari reports error: syntax error: DOM exception 12

Stackoverflow search problem: http://stackoverflow.com/questions/34620703/error-syntaxerror-dom-exception-12-setrequestheadernative-code

Reason: there cannot be spaces before and after attribute values in Ajax HTTP request headers

Project code:

config.headers.Authorization = ['Bearer ', $rootScope.JWT].join('');

Because the value of $rootscope.jwt may not exist, authorization is equal to ‘bearer’. Repair and conditional judgment are as follows:

if($rootScope.JWT) {
    config.headers.Authorization = ['Bearer ', $rootScope.JWT].join('');
}

Similar Posts: