JSFiddle - React, Tailwind, and code Playground

HTML

<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Simple $http.post in Angular - jsFiddle demo</title>
  
  <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'></script>
  <script type='text/javascript' src="http://code.angularjs.org/1.1.5/angular.min.js"></script>
    

</head>
<body ng-app='myApp'>
  <div ng-controller="myCtrl">
{{ response }}

<form ng-submit="sendPost()">
    key: <br/><input ng-model="key"/><br/>
    val: <br/><input ng-model="val"/><br/>
    <button type="submit">Send</button>
</form>
    
</div>

  


<script type='text/javascript'>//<![CDATA[ 

var myApp = angular.module('myApp', []);

myApp.config(['$httpProvider', function($httpProvider) {
  $httpProvider.defaults.useXDomain = true;
  delete $httpProvider.defaults.headers.common['X-Requested-With'];
}]);

angular.module('myApp').controller('myCtrl', function ($scope, $http) {

  $http.defaults.useXDomain = true;
  delete $http.defaults.headers.common['X-Requested-With'];
    
  $scope.sendPost = function() {

    $http.defaults.headers.common['Authorization'] = 'Basic dGVhbTE5QGF0dC5jb206dGVhbTE5cGFzcw=='
       
    $http.post('https://api.m2m.io/2/account/domain/ba4430edaf3b7aceb5df88f28de70c09/stuff/Arduino_Light/thing/device01/publish?topic=ba4430edaf3b7aceb5df88f28de70c09%2FArduino_Light%2Fdevice01%2Fcmd&payload=%7B%22key%22%3A%22' + $scope.key + '%22%2C%22val%22%3A%22' + $scope.val + '%22%7D').success(function(data, status) {
      $scope.response = data;
    });
        
  };     
    
});

//]]>  

</script>


</body>


</html>