我想在需要时调用 useQuery,
但是 useQuery 不能在函数内部。
我的尝试代码是:
export const TestComponent = () => {
...
const { data, loading, error } = useQuery(gql(GET_USER_LIST), {
variables: {
data: {
page: changePage,
pageSize: 10,
},
},
})
...
...
const onSaveInformation = async () => {
try {
await updateInformation({...})
// I want to call useQuery once again.
} catch (e) {
return e
}
}
...
Run Code Online (Sandbox Code Playgroud)
如何多次调用 useQuery?
我可以随时调用它吗?
我找了几个网站,但找不到解决方案。
我使用React,Express,MongoDB制作Web应用程序。
而且,我想通过头传递jwt令牌。
但是,我通过了它,得到401错误(未经授权)。
在登录actions.js中:
export function login(username, password) {
return function(dispatch) {
axios
.post(`${API_URL}/auth/login`, { username, password })
.then(res => {
dispatch(loginSuccess(res.data, username));
const token = res.data.token;
axios.defaults.headers.common["Authorization"] = token;
history.push("/");
})
.catch(err => {
if (err.response.status === 401) {
dispatch(loginFailure(err));
}
});
};
}
Run Code Online (Sandbox Code Playgroud)
并且,在服务器的post.js中:
getToken = function(headers) {
if (headers && headers.authorization) {
var parted = headers.authorization.split(" ");
if (parted.length === 2) {
return parted[1];
} else {
return null;
}
} else {
return null;
}
}; …Run Code Online (Sandbox Code Playgroud) 我安装了 NiFi 1.7.1 和 NiFi ToolKit。
并且,我尝试在 NiFi 中添加 LDAP 身份验证。
但是,我尝试登录 NiFI 登录页面,但出现错误“提供的用户名和密码无效。”
登录身份提供商.xml:
<provider>
<identifier>ldap-provider</identifier>
<class>org.apache.nifi.ldap.LdapProvider</class>
<property name="Authentication Strategy">SIMPLE</property>
<property name="Manager DN">CN=admin,OU=NIFI,DC=evidnet,DC=com</property>
<property name="Manager Password">passwd</property>
<property name="TLS - Keystore"></property>
<property name="TLS - Keystore Password"></property>
<property name="TLS - Keystore Type"></property>
<property name="TLS - Truststore"></property>
<property name="TLS - Truststore Password"></property>
<property name="TLS - Truststore Type"></property>
<property name="TLS - Client Auth"></property>
<property name="TLS - Protocol"></property>
<property name="TLS - Shutdown Gracefully"></property>
<property name="Referral Strategy">FOLLOW</property>
<property name="Connect Timeout">10 secs</property>
<property name="Read Timeout">10 secs</property> …Run Code Online (Sandbox Code Playgroud) 我希望加上所有单词的双引号.
这个例子.
ABC,DEF ,, JKL
我想转换:
"ABC", "高清", "", "JKL"
然后,我尝试转换,它失败了.我该怎么做?
sed "s/[^ ][^ ]*/'&'/g"
Run Code Online (Sandbox Code Playgroud) reactjs ×2
apache-nifi ×1
bash ×1
express ×1
graphql ×1
javascript ×1
jwt ×1
ldap ×1
mongodb ×1
react-apollo ×1
react-hooks ×1
sed ×1