JSFiddle - React, Tailwind, and code Playground
by jayrmotta
HTML
<div ng-app="cors">
<div ng-controller="SomeFancyController">
<button ng-click="fancyService.testBlockedConnection()">Test blocked connection</button>
<button ng-click="fancyService.testPostAllowedConnection()">Test post allowed connection</button>
<button ng-click="fancyService.testAllowedConnection()">Test allowed connection</button>
</div>
</div>
JavaScript
var app = angular.module('cors', []);
app.service('SomeFancyService', function($http) {
return {
testBlockedConnection : function() {
return $http.post('http://www.rastreamentocorreios.com.br/package/track');
},
testPostAllowedConnection : function() {
return $http.post('http://petstore.swagger.io/v2/user', {
"id": 0,
"username": "test",
"firstName": "test",
"lastName": "test",
"email": "[email protected]",
"password": "string",
"phone": "string",
"userStatus": 0
});
},
testAllowedConnection : function() {
return $http.get('https://api.github.com/repositories');
}
};
});
app.controller('SomeFancyController', function($scope, SomeFancyService) {
$scope.fancyService = SomeFancyService;
});