test-func.js 653 B

1234567891011121314151617181920212223242526
  1. testFunc()
  2. async function testFunc(){
  3. let response = await fetch("http://127.0.0.1:1337/api/ncloud/func",{
  4. method:"POST",
  5. headers: {
  6. "Content-Type": "application/json",
  7. },
  8. body:JSON.stringify({
  9. code:`
  10. module.exports.exampleFunc = function(params) {
  11. console.log('Hello from '+params?.title+'!');
  12. return "666!"+params?.title
  13. };
  14. `,
  15. func:"exampleFunc",
  16. params:{
  17. title:"NovaCloud Function Call"
  18. }
  19. })
  20. })
  21. let json = await response.json()
  22. console.log(json)
  23. }