# How to manage data offline and online in ionic

**URL:** <https://forum.ionicframework.com/t/how-to-manage-data-offline-and-online-in-ionic/38625>\
**Category:** ionic-v1\
**Created:** [December 7, 2015, 6:16am UTC](https://forum.ionicframework.com/t/how-to-manage-data-offline-and-online-in-ionic/38625 "2015-12-07T06:16:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hitubansal](https://avatars.discourse-cdn.com/v4/letter/h/85f322/32.png) [@hitubansal](https://forum.ionicframework.com/u/hitubansal)\
**Post date:** [December 7, 2015, 6:16am UTC](https://forum.ionicframework.com/t/how-to-manage-data-offline-and-online-in-ionic/38625/1 "2015-12-07T06:16:17Z")

</div>

Hello

I am working on blogging app . i want to save article list on SqlLite as well. I need to fetch all blogs in once. ( having more than 2000) blogs .

following is my controller code.

```
var promise= userService.getArticles();
promise.then(function(data) {
		$scope.articles = data;
}, function(error) {
  console.log('Failed for some reason:' + error);
});

```

factory code is

```
angular.module('starter.controllers')
.factory('userService', function($http,$q) {
	var articleList = [];

return {
		
			getArticles : function() {
				  var deferred = $q.defer();
				$http({
					url: "https://www.website.com/getallinfo?access_token=94529e5d",
					data: { starLimit: 0, endLimit: 150,created_date: 0 },
					method: 'POST',
					withCredentials: true,
				}).success(function (data, status, headers, config) {
						 deferred.resolve(data);

				}).error(function (err) {
					 deferred.reject(error); //
				})
				 return deferred.promise;
			},
		
	}

```

which is returing result.

I need to save that data in sqllite as well. Also i want to show data as offline.

I am not sure how to proceed this. Kindly help.

Thanks

---

<div class="post-metadata">

**Author:** ![bengtler](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/bengtler/32/98565_2.png) [@bengtler](https://forum.ionicframework.com/u/bengtler)\
**Post date:** [December 7, 2015, 6:45am UTC](https://forum.ionicframework.com/t/how-to-manage-data-offline-and-online-in-ionic/38625/2 "2015-12-07T06:45:55Z")

</div>

first of all:  
why are you “GETTING” data with a POST request???

and after that --\> add sqlite plugin and use the ngCordova wrapper for that:  
[http://ngcordova.com/docs/plugins/sqlite/](http://ngcordova.com/docs/plugins/sqlite/)
