0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

@ngrx/dataで別ドメインのAPIサーバにアクセスしてみる

0
Posted at

AngularのAdvent Calendarで@ngrx/dataが紹介されました。

Angularから@ngrx/dataとActiveRecordを使ってRDBにアクセスする(追記あり)

この記事で詳細に説明されているのですが、別ドメインのAPIにもアクセスできないかと思い試してみました。

別ドメインのAPIにアクセスするには

上記の記事の中でも紹介されていますが、デフォルトのAPIへのpathを変更するにはDefaultDataServiceConfigを使うだけです。

dataservice-config.ts
const defaultDataServiceConfig: DefaultDataServiceConfig = {
  root: 'https://api-server/user',
  timeout: 5000
};

rootの部分にAPIサーバのURLを設定してproviderに登録するだけです。

機会があれば複数のAPIサーバにアクセスさせる設計も考えます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?