http request stopped working

Hello,

I set up various http requests to pull data into my wix database - POSTS and PUTS. They were all working fine last week and now none of them work. I am connecting to a 3rd party app via Zapier and webhooks to Wix Code. I am getting this error in Zapier:

(‘Connection aborted.’, error(“(104, ‘ECONNRESET’)”,))

Other zaps with the same 3rd party app are working fine. I haven’t made any changes to the code. I may be missing something silly, but I have literally changed nothing from when they were working perfectly. Here is the code for one of them. Any help is greatly appreciated. Thanks.

‘use strict’;
import wixData from ‘wix-data’;
import {ok, response} from ‘wix-http-functions’;

export function post_storerecords (request) {

return request.body.json()
.then(body => {
if (body.secretKey === “”){
let dateTime = new Date(body.date_time);
let recordInsert = {
“title”: body.title,
“pro”: body.pro,
“clientFirstName”: body.clientFirstName,
“clientLastName”: body.clientLastName,
“clientEmail”: body.clientEmail,
“apptDate”: body.apptDate,
“apptTime”: body.apptTime,
“date_time”: dateTime,
“apptPrice”: body.apptPrice,
“amtPaid”: body.amtPaid,
“apptLocation”: body.apptLocation,
“apptType”: body.apptType,
“category”: body.category,
“duration”: body.duration,
“clientPhone”: body.clientPhone,
“calendarId”: body.calendarId,
“apptTypeId”: body.apptTypeId,
“formQuestion”: body.formQuestion,
“formClubs”: body.formClubs,
“formTopic”: body.formTopic,
“canceled”: body.canceled,
“classId”: body.classId

            }; 

return wixData.insert(‘Bookings’, recordInsert)
.then(result => ok({body: JSON.stringify(result)}))
. catch (err => response({status: 500, body: err}));

    } 
}); 

}

I don’t see headers, you need to return headers on your response

My post stopped working as well. It was more complicated, but I have since reduced it to the below to debug with no success. Please advise.

export function post_myFunction(request) {
// URL looks like: XXX Sex - Free Porn Videos at XXX.com
console.log(“I got to post function”);
return created();
}

Waiting for update.

Hi Emily and Samuel.
Can you please share the site’s url?

Thanks,
Genry.

https://emily4025.wixsite.com/instructorzone

www.smarthomesentry.com

Hi @echristy7 .
I have examined your site, and tried to republish the site - the issue was not resolved.

Then I have looked at the site’s code and our internal logs, and I saw that you have the following import in http-functions.js

import wixUsers from ‘wix-users’;

This import causes the JS file loading to fail, since wix-users module is intended to be used only in client side (public) code.
You already have an import of wix-users-backend there, so this module is designed to be used in the backend code.

If you will remove the above mentioned import from the file and publish - the http-functions should start working.

Best regards,
Genry.

Hi @samuel13108 .
I have examined your site, and there is a similar problem. In http-functions.js there is the following import:

import {local} from ‘wix-storage’;

This module is intended to be used on client side (public) code, and the presence of it in http-functions.js causes the loading of the file to fail.

If you will remove this import and publish the site - all should be working again.

Best regards,
Genry.

@genry-manashirov Thanks Genry. I’m back on track. As a product suggestion, the console should provide some feedback regarding file loading and errors. I would have not expected “Connection aborted” errors associated with a benign import statement that was not being used.