0
Good afternoon, so I’m doubting how to call a service in C#, I’ve tried several ways but failed.
(function () {
'use strict';
function Service($http, $q) {
const url = 'http://172.23.1.31:81/Service1.svc';
const servico = {
obterTodos: obterTodos,
excluir: excluir,
obter: obter,
criar: criar,
alterar: alterar
};
//Obter nomes banco de dados
function obterTodos() {
const promise = $http.get(url);
return promise.then(aoRequisicaoConcluir, aoRequisicaoFalhar);
}
//obter um apelido específico:
function obter(id) {
const urlComId = url + '/' + id;
const promise = $http.get(urlComId);
return promise.then(aoRequisicaoConcluir, aoRequisicaoFalhar);
}
//Excluir apelido
function excluir(id) {
const urlComId = url + '/' + id;
const promise = $http.delete(urlComId);
return promise.then(aoRequisicaoConcluir, aoRequisicaoFalhar);
}
//Criar apelido novo
function criar(TesteSafra) {
const promise = $http.post(url, TesteSafra);
return promise.then(aoRequisicaoConcluir, aoRequisicaoFalhar);
}
//Alterar um apelido:
function alterar(TesteSafra) {
const urlComId = url + '/' + TesteSafra.id
const promise = $http.put(urlComId, TesteSafra);
return promise.then(aoRequisicaoConcluir, aoRequisicaoFalhar);
}
//promise
function aoRequisicaoConcluir(response) {
return response.data;
}
function aoRequisicaoFalhar(response) {
return $q.reject(response.statusText);
}
return servico;
}
safraService.$inject = ['$http', '$q'];
angular.module('app')
.factory('Service', Service);
})();
Is this url correct? What is the answer to the request? In Chrome: F12 -> Network and see the result.
– Gabriel Coletta