- Do check in your code whether you have used context.close() anywhere after the function block as it might close the function before sending the response. This might have caused you the issue.
- The code within the function block will be executed only after the code outside the block is completed(normal Node.js behaviour). So we would suggest you to remove the basicIO.write() outside the function block as it might cause an error since data_output is not yet initialised.
- Make sure not to perform any operations after basicIO.write() as it is used for sending response back from the function which indicates the end of function execution.
- If the issue persists even after the above points, you can use a try catch block in your code to catch the exception and find out the issue.
You can find a sample Basic IO function for your operation as follows :
- const fetch = require('node-fetch');
- module.exports = (context, basicIO) => {
- var data_output;
- fetch('https://mms.zohosandbox.com/crm/v2/functions/mms__get_open_hours/actions/execute?auth_type=apikey&zapikey=1001.a9d79c98c63119fdad9fdfa1b910bead.71a47bc67b921811f2f5ce735aaab2a2')
- .then(function (response) {
- return response.json();
- })
- .then(function (myJson) {
- data_output = JSON.stringify(myJson);
- basicIO.write(data_output);
- context.close();
- });
- };