我有这个简单的服务,该服务接受并终结点并执行HTTP_CALL。如下所示:
export const updatePassword = (data: {
username: string;
password: string;
}): HttpResponse<string> => {
const { username, password } = data;
const options = {
method: httpMethod.POST,
url: endpoint.UPDATE_PASSWORD({
username,
password
})
};
return instance(options);
};
但是我得到这个错误:
Argument of type '{ username: string; password: string; }' is not assignable to parameter of type 'string'.
我不确定他是什么问题,因为我在上面几行做着完全相同的事情,但没有收到错误消息。
如果您需要我要命中的端点,则为:
UPDATE_PASSWORD: (username: string) => `${prefix}/${username}/password`,
此外,HttpRespone是AxiosResponse
泛型的扩展,而instance是AxiosRequestConfig
以及某些自定义泛型的扩展。
//更新。这是转换后的方式:
export const updatePassword = (data: { username: string }): HttpResponse<string> => {
const { username } = data;
const options = {
method: httpMethod.POST,
url: endpoint.UPDATE_PASSWORD(username)
};
return instance(options);
};
答案 0 :(得分:0)
您要查找的是JSON.stringify,而不是将您的JavaScript对象转换为JSON文本。
答案 1 :(得分:0)
您可以使 try (Connection con = DriverManager.getConnection(dbConnectionString, user, password);
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("SELECT * FROM public.\"Airplanes\" ")) {
while (rs.next()) {
//use result
}
} catch (SQLException ex) {
//handle exception
}
return results;
}
接受两个参数-一个用于用户名,另一个用于密码。
UPDATE_PASSWORD