Search Posts

Category: api

Looping through Angular API calls

I have a list of items and I want to pass the selected items to the API and check if that item exists or not. $scope.submitButton = function() { for (var i=0; i < $scope.selectedItems.length; i++) { console.log($scope.selectedItems[i]); // item2 myService.checkItem($scope.selectedItems[i]) .success(data, status, header, config) { var myData = data; console.log(myData); }) } } When I select item2 and click the button, I only want the service to return data for item2 but it returns […]

400 Bad Request during magento 2 REST API Call

When using $http.get in angular, I have a problem: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource….. $http({ method: ‘GET’, url: ‘https://<magento_host>/rest/default/V1/orders?searchCriteria[filter_groups][0][filters][0][field]=status&searchCriteria[filter_groups][0][filters][0][value]=processing,pending&searchCriteria[filter_groups][0][filters][0][condition_type]=in’, headers : { ‘Authorization’: ‘Bearer xxxxxxxxxxxxxxx’ } }).success(function (data) { }).error(function (data) { }); To avoid cross origin issue, I set below method in .htaccess file in Apache server. Header always set Access-Control-Allow-Origin “*” Header always set Access-Control-Allow-Methods “POST, GET, OPTIONS, PUT, DELETE” Header always set Access-Control-Allow-Headers: Authorization In […]

What is ‘API first architecture’ in modern web application

I try to understand the API first architecture to apply on web application, and found some info here, Advantages of a separate REST backend API? Below I attach an example for better answer of the questions. I start using Angular.js for front-end. Node.js, Express.js for server. folder structure |– server.js |– app |– models |– views |– index.html |– about.html |– contact.html |– controllers |– app.js |– node-modules app folder is a MVC structure for […]

Multiple api calls using AngularJS

I am fairly new to AngularJS and I am practising below exercise with requirement 1.Using the API to get 20 posts and display them on the page along with the user’s name who created the post and display them on the page. For this exercise I am using as the data source. I need to do 2 api calls in same controller To get list of 20 posts which has userid in it( Based […]

RESTFUL App in symfony 3

I am still quite confused about REST API, Angular and so on. I would like to build simple web app which allows users to book events and I would like to do it in Symfony 3 + Angular. In future, I could make it work on mobile phones as well. The reason I want to do it is to learn symphony 3, REST API and Angular better and to increase chance I will get hired. […]