我需要使用javascript删除用户表单解析sdk,我尝试加载用户查询然后调用destroy()但它给了我:
[HTTP / 1.1 400错误请求]
我的代码在这里
var query = new Parse.Query("User");
query.equalTo("email", 'wathmal@hotmail.com');
query.find().then(function(results) {
console.log(results[0]);
results[0].destroy();
});
这不会破坏用户。有人可以帮忙吗?
答案 0 :(得分:1)
var CurrentUser = Parse.User.current();
console.log(CurrentUser);
var sessiontoken;
Parse.User.logIn(CurrentUser.attributes.username, document.getElementById("curpassword").value, {
success: function (user) {
user.set("StayLoggedIn", "false");
console.log(user._sessionToken);
sessiontoken = user._sessionToken;
user.save();
$.ajax({
url: 'https://api.parse.com/1/users/' + user.id,
type: 'DELETE',
headers: {'X-Parse-Application-Id': APP_ID, 'X-Parse-REST-API-Key': REST_KEY, 'X-Parse-Session-Token': sessiontoken},
success: function (result) {
// Do something with the result
alert("you have successfully deleted your account.");
Parse.User.logOut();
window.location.href = "index.html";
}
});
// location.reload();
},
error: function (user, error) {
//alert(error);
alert("incorrect username or password");
}
});