index.js 921 B

1234567891011121314151617181920212223242526272829303132333435
  1. 'use strict';
  2. const db = uniCloud.database();
  3. exports.main = async (event, context) => {
  4. let result = JSON.parse(event.body)
  5. //event为客户端上传的参数
  6. let formData = {
  7. "app_status": result.type,
  8. "user_name": result.phone,
  9. "user_brand": result.phoneType.brand,
  10. "user_model": result.phoneType.model,
  11. "api_src": result.request.url,
  12. "request_parameters": result.request.data,
  13. "response_parameters": result.response[1].data,
  14. "api_status": result.response[1].data.code,
  15. "error_info": "7"
  16. }
  17. const collection = db.collection('cyt-logs');
  18. let res = await collection.add(formData)
  19. // db.collection('cyt-logs').add(formData).then((res) => {
  20. // uni.showToast({
  21. // title: '新增成功'
  22. // })
  23. // }).catch((err) => {
  24. // uni.showModal({
  25. // content: err.message || '请求服务失败',
  26. // showCancel: false
  27. // })
  28. // })
  29. return {
  30. code: 200,
  31. msg: "成功",
  32. data: res.data
  33. }
  34. };