【发布时间】:2018-12-15 17:03:54
【问题描述】:
我正在尝试使用 axios 从 react native 向我的coldfusion组件发送一个get请求。
我的冷融合组件:
component displayName="react" {
remote any function ajaxLogin(data) returnformat="JSON"{
data = deserializeJSON(arguments.data);
return serializeJSON(login(data));
}
private any function login(data){
loginQuery = new query();
loginQuery.setDatasource("ds");
loginQuery.setName("loginQuery");
loginQuery.addParam(name="UserEmail", value="#arguments.data.userEmail#", cfsqltype="cf_sql_varchar");
loginQuery.addParam(name="UserPW", value="#arguments.data.userPassword#", cfsqltype="cf_sql_varchar");
result = loginQuery.execute(sql="SELECT * FROM Users Where UserEmail = :UserEmail AND UserPW = :UserPW");
rs = result.getResult();
if(rs.recordCount == 0){
return 0;
} else {
return rs.UserID;
}
}
}
我的 react-native 调度操作:
export const loginUser = ({ email, password }) => {
// login
return (dispatch) => {
dispatch({ type: 'TEST' });
axios.get('https://myserver.com/components/reactNative/react.cfc?method=ajaxLogin', {
params: {
userEmail: email,
userPassword: password
}
})
.then((response) => {
console.log(response.data);
})
.catch((err) => {
console.log(err);
});
};
};
它从 catch 返回一个错误:
Error: Request failed with status code 500
我是 axios 和 react-native 的新手。我使用axios错了吗?
谢谢
【问题讨论】:
-
您应该在浏览器中查看请求的内容
-
我该怎么做?
-
使用 react-native-debugger github.com/jhen0409/react-native-debugger
标签: react-native coldfusion axios