# API Calls using Shared Library/Module

**URL:** <https://forum.ionicframework.com/t/api-calls-using-shared-library-module/100696>\
**Category:** ionic-v3\
**Created:** [August 3, 2017, 9:38am UTC](https://forum.ionicframework.com/t/api-calls-using-shared-library-module/100696 "2017-08-03T09:38:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![abhibly](https://avatars.discourse-cdn.com/v4/letter/a/b77776/32.png) [@abhibly](https://forum.ionicframework.com/u/abhibly)\
**Post date:** [August 3, 2017, 9:38am UTC](https://forum.ionicframework.com/t/api-calls-using-shared-library-module/100696/1 "2017-08-03T09:38:49Z")

</div>

Hello i have developed a mobile and web app which needs to share the same business logic and API [calls.So](http://calls.So) i created a library with the help of this blog [https://hackernoon.com/how-to-create-library-in-angular-2-and-publish-to-npm-from-scratch-f2b1272d6266](https://hackernoon.com/how-to-create-library-in-angular-2-and-publish-to-npm-from-scratch-f2b1272d6266) and published the library.I installed the library in my mobile app.The business logic code is working fine but i am facing issues with API calls.I am getting the following error

```auto
No provider for AuthHttp!

```

This is how my `app.module.ts` in my mobile app

```auto
import { AuthHttp, AuthConfig } from 'angular2-jwt';

    import { HttpModule, Http, JsonpModule,RequestOptions } from '@angular/http';

    export function getAuthHttp(http, storage) {
       return new AuthHttp(new AuthConfig({
       headerName: 'Authorization',
       headerPrefix: 'Bearer',
       tokenName: 'id_token',
       noJwtError: true,
       globalHeaders: [{ 'Accept': 'application/json', 'Content-Type': 
       'application/json' }],
        tokenGetter: (() => storage.get('id_token')),
       }), http);
      }

     @NgModule({
      declarations: [
       MyApp,HomePage],
      imports: [
        BrowserModule,
        HttpModule,
        SharedModule,
        IonicModule.forRoot(MyApp)
      ],
      bootstrap: [IonicApp],
      entryComponents: [
        MyApp,
        HomePage
      ],
      providers: [
       {
         provide: AuthHttp,
         useFactory: getAuthHttp,
         deps: [Http, Storage]
       }
     ]
    })

```

This is how my SharedLibrary module code looks

```auto
import { NgModule, } from '@angular/core';
    import { EmptyTextDirective } from './empty-text.directive';
    import { EmptyTextService } from './empty-text.service';
    @NgModule({
      exports: [EmptyTextDirective],
      declarations: [EmptyTextDirective],
      providers: [EmptyTextService],
     })
     export class SharedModule { }

```

And the emptytextservice.ts code is

```auto
import { Injectable } from '@angular/core';
    import { AuthHttp } from 'angular2-jwt';
    @Injectable()
    export class EmptyTextService {
        emptyTextDisplay:string = "empty";
        constructor(public authhttp:AuthHttp) {}
        get(){
             return this.authhttp.get(someurl).map((data)=>{
                 return data.json();
              });
        }
     }

```

I have configured authhttp in my app.module because i am using the shared module in both mobile and web [app.so](http://app.so) the token which is generated is stored in session storage for web app and ionic storage for mobile.can somebody please tell me how can i share the api calls done using angular2 jwt.

Thank you
