superagent全局.end函数处理程序

时间:2016-01-18 05:53:10

标签: javascript ajax superagent

如何添加superagent全局端处理程序?

我正在使用superagent来执行ajax数据获取工作。

<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<!-- Content View - include your main layout here -->
<include layout="@layout/activity_main" />

<!-- Drawer view -->
<android.support.design.widget.NavigationView
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <!-- TODO Add Spinner views here -->

    </LinearLayout>

</android.support.design.widget.NavigationView>

我想为每个请求添加request.get('/some/end/point/').end(function(err, res) { if (res.status === 401) { // redirect to login } else { //do something with the data } }); 检查,

可能吗?

0 个答案:

没有答案