2016-10-06 8 views
0

私はMETEORアプリケーション用にAPIを作成しようとしています。 私はhttps://atmospherejs.com/simple/resthttps://atmospherejs.com/xcv58/collection-apiを見ましたが、うまくいきませんでした。 今、私はrestivus上だ:私が得たhttps://atmospherejs.com/nimble/restivusRestivusはHTMLテンプレートを返しますか?

問題は、私は、APIを呼び出すためにしようとしているとき、それは常に私のHTMLテンプレートを返すことで、そうでない場合、私はJSONレスポンスを必要とする...

これはserver.jsで=>

APIのための私のコードです:

// Global API configuration 
    var Api = new Restivus({ 
     apiPath: 'api/', 
     auth: { 
      token: 'auth.apiKey', 
      user: function() { 
      return { 
       userId: this.request.headers['user-id'], 
       token: this.request.headers['login-token'] 
      }; 
      } 
     }, 
     defaultHeaders: { 
      'Content-Type': 'application/json' 
     }, 
     onLoggedIn: function() { 
      console.log(this.user.username + ' (' + this.userId + ') logged in'); 
     }, 
     onLoggedOut: function() { 
      console.log(this.user.username + ' (' + this.userId + ') logged out'); 
     }, 
     prettyJson: true, 
     useDefaultAuth: true, 
     version: 'v1' 
    }); 

    Api.addCollection('coupons'); 

私はいくつかのユーザー名とパスワードのデータとhttp://localhost:3000/api/v1/login/にカールをしようとすると、それは私にすべての私のHTMLテンプレートを返します...

誰かが解決策を知っているか、既にこの問題がありますか?あなたの将来のため答え

感謝:)

答えて

0

問題は、ドキュメントが使用に対して警告APIオプションのセットを使用していることです。コードhereの真上のコメントを確認してください。コードをコピーして貼り付ける場合は、code from the quick start exampleを使用します。探しているAPIを入手するには、次のものが必要です:

var Api = new Restivus({ 
    useDefaultAuth: true, 
    version: v1 
}); 

Api.addCollection('coupons'); 
関連する問題