现在我有了我的后端服务,可以通过以下网址向我们的系统注册新用户:
let DeviceInfo = [
"ImageUrl":profileImageUrl!,
"DeviceName":self.DeviceName.text!,
"Description":self.Description.text!,
"Category":self.itemSelected
]
self.ref.child("Devices").child(FIRAuth.auth()!.currentUser!.uid).observeSingleEventOfType(.Value, withBlock: {(snapShot) in
if snapShot.exists(){
let numberOfDevicesAlreadyInTheDB = snapShot.childrenCount
if numberOfDevicesAlreadyInTheDB < 5{
let newDevice = String("Device\(numberOfDevicesAlreadyInTheDB+1)")
let userDeviceRef = self.ref.child("Devices").child(FIRAuth.auth()!.currentUser!.uid)
userDeviceRef.observeSingleEventOfType(.Value, withBlock: {(userDevices) in
if let userDeviceDict = userDevices.value as? NSMutableDictionary{
userDeviceDict.setObject(DeviceInfo,forKey: newDevice)
userDeviceRef.setValue(userDeviceDict)
}
})
}
else{
//Show Alert that user cant enter Devices Anymore
}
}else{
self.ref.child("Devices").child(FIRAuth.auth()!.currentUser!.uid).setValue(["Device1" : DeviceInfo])
}
})
使用Restangular总是会导致帖子请求以查询字符串
的形式发送/api/users/register
或标题
Restangular.all('users').post("register",registerData)
这里的问题,如何将注册表单参数作为有效负载发布?
答案 0 :(得分:0)
尝试将数据作为第一个参数发送:
Restangular.all('users').one("register").customPOST({name:"xyz"}, '', {}, {});
https://github.com/mgonto/restangular/blob/master/README.md处的文档似乎已经完整。很高兴看到!