JSON YAPISI
http
GET(LİSTELE)
$http({
method: 'GET',
url: 'https://jsonplaceholder.typicode.com/users'
}).then(function successCallback(response) {
}).then(function successCallback(response) {
$scope.users = response.data;
},
function errorCallback(response) {
alert("hata tekrar dene");
});
http
POST(EKLE)
$http({
method: 'POST',
url: 'https://jsonplaceholder.typicode.com/users',
data: $scope.user
}).then(function successCallback(response) {
$scope.users.push(response.data);
alert("kullanıcı eklendi")
},
function errorCallback(response) {
alert("hata tekrar dene");
});
http
PUT ( GUNCELLE )
$http({
method: 'PUT',
url: 'https://jsonplaceholder.typicode.com/users/' + $scope.user.id,
data: $scope.user
}).then(function successCallback(response) {
alert("KULLANICI GUNCELLENDİ")
},
function errorCallback(response) {
alert("HATA TEKRAR DENE");
});
http DELETE (SİL)
$http({
method: 'DELETE',
method: 'DELETE',
url: 'https://jsonplaceholder.typicode.com/users/' + user.id
}).then(function successCallback(response) {
}).then(function successCallback(response) {
alert("KULLANICI SİLİNDİ");
var index = $scope.users.indexOf(user);
$scope.users.splice(index, 1);
},
function errorCallback(response) {
alert("HATA TEKRAR DENE");
});
HTTP ÖRNEK: https://embed.plnkr.co/wWmWv3/
Hiç yorum yok:
Yorum Gönder