test.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. async function getStudentByNo(stuno){
  2. let whereCondition = ``
  3. if(stuno){
  4. whereCondition = `\"where\":{\"stuno\":\"${stuno}\"},`
  5. }
  6. let response = await fetch("http://web2023.fmode.cn:9999/parse/classes/LcmUser", {
  7. "headers": {
  8. "accept": "*/*",
  9. "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
  10. "content-type": "text/plain"
  11. },
  12. "referrer": "http://localhost:4040/",
  13. "referrerPolicy": "strict-origin-when-cross-origin",
  14. "body": `{`+whereCondition+`\"limit\":200,\"order\":\"createdAt\",\"_method\":\"GET\",\"_ApplicationId\":\"dev\",\"_ClientVersion\":\"js3.4.2\",\"_MasterKey\":\"devmk\",\"_InstallationId\":\"6ea3aea6-b781-4fba-b709-5de81c8a0fda\"}`,
  15. "method": "POST",
  16. "mode": "cors",
  17. "credentials": "omit"
  18. });
  19. let result = await response.json();
  20. if(stuno){
  21. return result?.results?.[0]
  22. }else{
  23. return result?.results
  24. }
  25. }
  26. module.exports.getStudentByNo = getStudentByNo
  27. async function main() {
  28. let student = await getStudentByNo("007");
  29. console.log(student)
  30. console.log(student?.objectId)
  31. let studentList = await getStudentByNo();
  32. console.log(studentList)
  33. }
  34. main()
  35. module.exports.getStudentByNo = getStudentByNo