javascript - custom header angular js -


i trying add customer header in request angular js first time, getting following error

angular.js:10671error: failed execute 'setrequestheader' on 'xmlhttprequest': 'x-api-key:' not valid http header field name.

here code, @ highest 'app' level:

var movieapp = angular.module('movieapp', ['nganimate']);  movieapp.config(['$httpprovider', function ($httpprovider) {     $httpprovider.defaults.headers.common = {          'x-api-key:' : 'key'       }; }]) 

what doing wrong/missing/not understanding? how can add header (or one) request?

as error explains, x-api-key not valid http header field. can go here official documentation, or look @ wikipedia. fix this, have pass api key parameter in request body.


Comments