0
私はHTTP要求に対してスーパーエージェントを使用していますが、エラーと必要なリダイレクトを管理するためにスーパーエージェントインターセプトを使用してHTTP要求をキャッチしようとしています。Vue JS/superagent - TypeError:fnが関数ではありません
forms.get = function(root, cb) {
request
.get(`${api}/forms/name/FORM`)
.use(interceptor.auth)
.use(nocache)
.withCredentials()
.set('Accept', 'application/json')
.end(function(err, res) {
if (res.body.status === 'success') {
cb(res.body.data.forms, root)
} else if (common.token(res)) {
common.cb(root);
} else {
console.log("error");
}
});
};
を考慮:
interceptor.auth = require('superagent-intercept')((error, results) => {
// Error handling ..
});
しかし、私はGLOBAL_DATAにエラーが発生している呼び出す
GLOBAL_DATA({commit, state}) {
forms_store.get(null, (result) => {
commit('SET_FORMS', result)
});
}
:componant私はVuexからアクションを呼び出す実装されている
:
TypeError: fn is not a function
ある時点で何かが上書きされていると思いますが、修正する方法がわかりません。
編集:
私は最初の関数の構文を変更しますが、私はまだ同じエラーを持っている:
GLOBAL_DATA : (context) => {
forms_store.get(null, (result) => {
context.commit('SET_FORMS', result)
});
を私は自分のコードを編集し、投稿、しかし私はまだ非常に同じエラーがあります。あなたは何が起こっているか考えていますか? – kwn