0

We're trying to develop an app to interact with Horizon Stellar Server. We are new in the area and we¿re trying to Angular 8 and Ionic 4, but we havent been able to import the js-stellar-sdk successfully. I created a brand new app to test but it fails to compile.

Tried this: using stellar-sdk in angular But I get StellarSdk is not defined and Server is not a constructor/function (when I comment the declaration).

Also found this: https://github.com/stellar/js-stellar-base/issues/128 but they said its already fixed: https://github.com/stellar/js-stellar-base/issues/128#issuecomment-474474028 Wanted to try this: https://github.com/stellar/js-stellar-base/issues/128#issuecomment-391374590 But it seems its no longer created in Angular 8 (dont know if I have to created it).

this is my app.component.ts:

import { Component, OnInit } from '@angular/core';
import { Server } from 'stellar-sdk';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit{
  title = 'example';
  server: any;

  ngOnInit(): void{
    this.server = new Server('https://horizon.stellar.org');
  }  
}

I get the following error:

ERROR in ./node_modules/eventsource/lib/eventsource.js Module not found: Error: Can't resolve 'http' in 'C:\Users\Rafael Cisneros\Desktop\Work\Ionic\example\node_modules\eventsource\lib' ERROR in ./node_modules/eventsource/lib/eventsource.js Module not found: Error: Can't resolve 'https' in 'C:\Users\Rafael Cisneros\Desktop\Work\Ionic\example\node_modules\eventsource\lib'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.