How to use json api

i want to use a json api to fetch data from json url api, can you suggest me the solution.

Right now i’m create some Factory to wrap my api request, then call it like this

.factory('KreditService', function($http, $localStorage) {
    return {
        cekBaki : function(postData) {
            return $$localStorage.apiUrl + '/kredit/cek-baki', postData, {timeout: $localStorage.connectionTimeout});
        cekTunggakan : function(postData) {
            return $$localStorage.apiUrl + '/kredit/cek-tunggakan', postData, {timeout: $localStorage.connectionTimeout});
        pembayaranAngsuran : function(postData) {
            return $$localStorage.apiUrl + '/kredit/pembayaran-angsuran', postData, {timeout: $localStorage.connectionTimeout});

Its then return a promise, then from my controller i call it with

            .success(function(res) {

                $scope.result   = res;

                data.rekening   = = ""
            .error(function(res) {

                    content: res ? res.error.message : $translate('ajax_timeout')

Something like that :smile:

Thank you, let me try.

i want to use this api.

how can i do ? to show profile.

You can also use angular-resource, which is a wrapper around $http.$resource

what you suggest is good to use this api.

Can any one give me a good example to use json api . to show profile and many data.

The Angular docs for $http have have examples for get, post and jsonp.$http

You could also use an Angular resouce for REST based services$resource

any sample project in github or can you please give me the sample code where to write and put api and how to call in html.

The angular $http doc has examples and that’s what I used to get up and running.
Plenty of examples on StackOverflow too. Maybe try some code out and if you get stuck post what you’ve got and someone may help.

Thank you , i will try still if you give some examples it will help me, i found lot of things so confused which one i use.

You could try this (adapted from the Angular $http docs that I posted):

var myUrl =;    

 // Simple GET request example :

      success(function(data, status, headers, config) {
        // this callback will be called asynchronously
        // when the response is available
      error(function(data, status, headers, config) {
        // called asynchronously if an error occurs
        // or server returns response with an error status.
       console.log('ERROR ' + status);

In Ionic frame work, in controller.js,services.js and app.js in which file what we write and in html how we call this, can you please help me…

Sorry, I have been as helpful as I am able to be at this point. I think the real issue here is a lack of knowledge of Angular. I recommend that you work through some basic beginner Angular tutorials and then read the docs for $http service that I posted. Then you wil find all the Angular examples a lot easier to understand.

okey. but if you just guide in controller and services and app .js how i write and call in ionic it will help me lot…

You can use the $http service in either a controller or a service.
The example at the bottom of the $http docs shows how to fetch data in the controller, assign it to a $scope variable and show it in html.

do you have any app that is exist in github so i can follow.

No, sorry. What is ist about that example you don’t understand?

here is my controller 
.controller('ProfileCtrl', ['$scope', 'Evenimente', function($scope, Evenimente){
        $scope.profile = [];
        Evenimente.getAll().then(function (profile) {
          $scope.profile = profile;
        }, function (response) {
            // our q.reject gets the reponse and you can handle an error
            console.log("Rejected connection for Evenimente");

here is my services 
'use strict';

 angular.module('', [])
.factory('Evenimente', ['$http', '$q', function($http, $q){
  return {
    getAll: function(){
      var myPromise = $q.defer();
                  myPromise.resolve(; // resolve our promise -> success
               }, myPromise.reject); // reject our promise -> fail / error case
      return myPromise.promise;

can you please check what is correct format to write this...

Please can you edit your post with formated code? You can use thr </> symbol in the post editor to help. Thanks