Search Posts

Category: rest

populate a drop down of states from a country list – angularjs

Below is my snippet from java spring controller to return a list of states Here is the sample json result from postman to fetch states in respect to country id. [ { “id”: 1, “name”: “state1”, “country”: { “id”: 1, “name”: “MyCountry” } }, { “id”: 2, “name”: “state2”, “country”: { “id”: 1, “name”: “MyCountry” } }, { “id”: 3, “name”: “state3”, “country”: { “id”: 1, “name”: “MyCountry” } }, { “id”: 4, “name”: “state4”, […]

ui-router — data service called in view1 not showing in view2

Web service isn’t working correctly, not sure if that is the issue new to AngularJS and HTML in general and trying to figure out an additional issue to a previous question I had. What I am trying to do is to display the information from my web service onto the page I’ve created: $scope.clickFunc = function () { $scope.isNewSite = false; $scope.isModifySite = true; var siteId = Number($stateParams.siteId); SpringDataRestService.get( { “collection”: “sites”, “resource”: siteId }, […]

Getting error 401 with $http get and XMLHttpRequest but it’s working with postman

I have received a api from client and when I am trying to integrate it with angular service, getting 401 unauthorized error. But same is working with POSTMAN. Please suggest me if I am doing anything wrong. Here is the code which I am trying: $http({ url: “https://xxx_test.com/data?sdate=date”, method: “GET”, headers: { ‘apikey’: ‘S0GgF7zFEvA38GUQmPFGdcXpWPvnpHla’ }, }) This is the response that I am getting : {“fault”:{“faultstring”:”Failed to resolve API Key variable request.header.apikey”,”detail”:{“errorcode”:”steps.oauth.v2.FailedToResolveAPIKey”}}} Source: AngularJS

Codeigniter 3.0 CSRF security on angular js 1.x is getting 500 error on $http.post() method

Codeigniter CSRF security on angularjs 1.x is getting 500 error on $http.post() method . Its worked for me on form submission(ordinary form action submit),but when i use angular ajax for same form submission i am getting 500.Please help me var angCntrl = angular.module(‘stepsReg’,[‘ngMaterial’, ‘ngMessages’, ‘material.svgAssetsCache’,’mdPickers’,’naif.base64′,’ngFileUpload’,’uiCropper’,’ngCookies’]) angCntrl.controller(‘DemoCtrl’, function($scope,$window, $cookies,$http,$mdpDatePicker,$mdpTimePicker,$timeout,$q,$mdDialog,$filter,Upload) { var cct = $cookies.get(‘csrf_cookie_name’); $scope.insertid = ”; $scope.outletid = ”; $scope.currentid = currentid; $scope.stepOneNext = function() { var insertid = $(‘#insertid’).val(); var profileId = $(‘.current_id’).val(); var […]

$http get to REST service not showing in component template

Using the following code, i am able to do a http get from a json file, however when i try to run a http get against a REST service URL the angular webpage does not display the data on the form. When i go to the browser developer tools i can see the response data, it does not display the results on the page. Any help is appreciated. This is the controller i have – […]

How to send an object and array through Angularjs service

I am trying to send an object and array in the same time to an API, but i got an error This is the object (from input boxes) var vacation = { Vac_Main_Key: $scope.vackey, Vac_Main_Code: $scope.code, Gender_Type: $scope.gen, CareeService_Flag: $scope.career, Vac_Duration: $scope.vduration, Duration_Flag: $scope.vflag} This is the array (from multiple check boxes) $scope.selectedcontract = function (con) { if (con.details == true) { $scope.vacationcontracts.push({ VacMKey: $scope.vackey, WType: con.sys_key }); console.log($scope.vacationcontracts); } else if (con.details == false) […]

How to construct Loopback.js rest api URLs client side?

I am using loopback.js as a rest api server and angular sdk provided by IBM. My question is quite simple: Must I always construct client URLS to follow my Rest API URLs ? Sample: Must all my link point to http:/// …/api/Vn/ … ? My problem is that urls generated by ui-router are not the same than the urls coming from API server. I thank you in advance for your help. Source: AngularJS

Required request body is missing : Possibly unhandled rejection

I have a working service that returns 3 rows successfully(tested with postman extension). But I can’t seem to get data while calling from .js :- $scope.showRecord = function() { $http.get(“http://vlinux:9099/GetAwards”).then(function(response) { $scope.configs = response.data; alert(reponse.data); }); } I get this :- angular.min.js:125 Possibly unhandled rejection: {“data”:{“timestamp”:”2018-05-04T09:42:11.231+0000″,”status”:400,”error”:”Bad Request”,”message”:”Required request body is missing: Here’s my service code :- @RequestMapping(“/GetAwards”) @Consumes(MediaType.APPLICATION_JSON) public List<AwardConfig> retrieve(@RequestBody String input) { return dao.select(); } Source: AngularJS

$http.get does not call the backend if called twice to quick

I have a case in AngularJS where if I call the $http.get(‘/sameresource’) for the same resource method twice fast one after the other, then I see (from debugging) that the backend is called only one time, although when I debug in Firefox (or Chrome) it seems that the second call works, and the callback is then also called. It is supposed that the first call to make some changes in the backend and so should […]

Next Page »