来自Parse的PATCH https请求 [英] PATCH https request from Parse
问题描述
我正在尝试从Parse Cloud代码发出https PATCH请求(更新Firebase应用程序中某个对象的部分),我遇到了以下问题:
I'm trying to make an https PATCH request from Parse Cloud code (to update part of an object in a Firebase application), and I'm running into the following issues:
- Parse.Cloud.httpRequest不支持PATCH,而是执行GET请求,因此我尝试使用Node.js https模块来执行请求,但是:
- https模块未包含在Parse Cloud Code中,我不知道如何包含它
是否有人尝试过类似Parse的东西?
Anyone having tried something similar with Parse?
现在我的后备是做一个PUT请求而不是更新整个对象,但是如果有人有一些经验这些问题很棒
For now my fallback is to do a PUT request instead an update the whole object, but if anyone has some experience with these issues that'd be great
编辑:Parse的某个人回复了 here 表示他们不支持PATCH请求现在但将在fut中做
Someone from Parse just replied here saying that they don't support PATCH requests as of now but will do in the future
推荐答案
Parse.Cloud.httpRequest({
method : 'POST',
headers : {
'Content-Type': 'application/json',
'X-HTTP-Method-Override': 'PATCH',
},
url : 'https://dev-xxxxxxx.firebaseio.com/users/91'+userNumber+'.json',
body : {
"code" : code
},
试试这个,然后是成功和错误块。这个对我有用!您需要将方法类型设置为 POST
并在标题中添加此额外行:
Try this, followed by a success and error block. It works for me! You need to set method type as POST
and this extra line in headers:
'X-HTTP-Method-Override': 'PATCH',
这篇关于来自Parse的PATCH https请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!