Simple HTML request / $w().postMessage code no longer working for business site

Hi all,

On my client’s Wix site, the code I wrote to perform a simple HTML request and use $w().postMessage to pass the data to a Wix HTML custom element is no longer working.

See an example of the Page code here:

import { fetchVideos } from 'backend/fetch-videos.jsw';

$w.onReady(() => {
 const element = "#html1";
 const tag = "all";

 fetchVideos(tag)
     .then((videos) => {
         $w(element).postMessage(JSON.stringify(videos));
     })
     .catch(err => console.log(err.message));
});

As the code still works in the editor and the request functions fine independently of the site (and worked for months on the site previously), I believe the issue has something to do with how Wix is rendering the page, but I’m not certain as the only error messages I am getting in the console are errors related to “frog.wix.com”, such as “POST https://frog.wix.com/ net::ERR_BLOCKED_BY_CLIENT”.

I believe it may be similar to this user’s problem: https://www.wix.com/corvid/forum/community-discussion/i-ve-had-enough-of-wixs-corvid-api-and-site-builder-constant-problems-and-now-users-get-stuck-on-product-page

This code is relatively simple, has been well tested and in use for months now without issue, and is necessary to support my client’s business. Is anyone able to help with this error? If so please let me know if there is more information I can provide to quickly resolve this issue.

Thank you!

I’ve got the same issu accept I am not sure what is generating my page’s problem :tired_face:

// For full API documentation, including code examples, visit http://wix.to/94BuAAs
import { session } from ‘wix-storage’ ;
import wixData from ‘wix-data’ ;
import wixLocation from ‘wix-location’ ;

$w.onReady( function () {
//constructDealerships();
constructCarPlans();
});

export async function constructCarPlans() {
////console.log(“\n\n\nWe are in setInitailValuesAdvertising”);
loadTransactionsTable();
$w( “#CarPlanSaverPriceText” ).text = “” ;
$w( “#CarPlanStandardPriceText” ).text = “” ;
$w( “#CarPlanExecutivePriceText” ).text = “” ;
let adpackagesResults = await wixData.query( “carpackages” ).ascending( “apId” ).find();
$w( “#CarPlanSaverPriceText” ).text = “R” + adpackagesResults.items[ 2 ].apPrice + " p.m." ;
$w( “#CarPlanStandardPriceText” ).text = “R” + adpackagesResults.items[ 1 ].apPrice + " p.m." ;
$w( “#CarPlanExecutivePriceText” ).text = “R” + adpackagesResults.items[ 0 ].apPrice + " p.m." ;

$w( "#CarPlanSaverPlanCheckbox" ).checked =  **true** ; 
$w( "#CarPlanStandardPlanCheckbox" ).checked =  **false** ; 
$w( "#CarPlanExecutivePlanCheckbox" ).checked =  **false** ; 

//carPlansChanged(2);

$w( "#CarPlanPromoMessagesText" ).text =  "" ; 

}

export async function loadTransactionsTable() {
//console.log(“\n\nLoading transaction table”);
try {
$w( “#TransactionsMessagesText” ).text = “Loading all transactions…;”
$w( “#TransactionsProgressBar” ).value = 10 ;
//Get all of the transactions related to the dealership owner’s userId and cross reference with all of the dealerships
//Step1 get all the dealership Ids based on the userId
const dealershipWorkers_userId_results = await wixData.query( “dealershipWorkers” ).eq( “userId” , parseInt(session.getItem( “userId” ), 10 )).find();
$w( “#TransactionsMessagesText” ).text = “Loading all transactions.;”
$w( “#TransactionsProgressBar” ).value = 20 ;
//Step2 assign each dealershipId to a array of dealership Ids
let dealershipIds = [];
//console.log("Number of userId search results: " + dealershipWorkers_userId_results.items.length);
//console.log(“Getting dealership Ids”);
for ( let dealershipIdCounter = 0 ; dealershipIdCounter < dealershipWorkers_userId_results.items.length; dealershipIdCounter++) {
//console.log("Dealership Id: " + dealershipWorkers_userId_results.items[dealershipIdCounter].dealershipId);
dealershipIds.push(dealershipWorkers_userId_results.items[dealershipIdCounter].dealershipId);
}
$w( “#TransactionsMessagesText” ).text = “Loading all transactions…;”
$w( “#TransactionsProgressBar” ).value = 30 ;
//Step3 get all of the dealerships owners’ userIds
let dealershipOwnerUserIds = [];
for ( let dealershipIdCounter = 0 ; dealershipIdCounter < dealershipIds.length; dealershipIdCounter++) {
const dealerships_userId_results = await wixData.query( “dealerships” ).eq( “dealershipId” , dealershipIds[dealershipIdCounter]).find();
//console.log("Dealership owner user ID: " + dealerships_userId_results.items[0].userId);
dealershipOwnerUserIds.push(dealerships_userId_results.items[ 0 ].userId);
}
$w( “#TransactionsMessagesText” ).text = “Loading all transactions…;”
$w( “#TransactionsProgressBar” ).value = 50 ;
//Step 4 delete repeated owner user Ids
// pass a function to map
const userIdMapper = dealershipOwnerUserIds.map(userId => userId);
dealershipOwnerUserIds = [… new Set(userIdMapper)];
$w( “#TransactionsMessagesText” ).text = “Loading all transactions.;”
$w( “#TransactionsProgressBar” ).value = 70 ;
//console.log(“No duplicate user ID list: \n” + dealershipOwnerUserIds);
//console.log("Number of userIds: " + dealershipOwnerUserIds);

//Step 5 look up all the transactions using the dealerships owners’ userIds
let transactions = [];
for ( let userIdCounter = 0 ; userIdCounter < dealershipOwnerUserIds.length; userIdCounter++) {
let transactions_userId_results =
await wixData.query( “transactions” )
.eq( “userId” , dealershipOwnerUserIds[userIdCounter]).eq( “transactionType” , “Carplan” )
.eq( “transStatus” , ‘Approved’ )
.or(
wixData.query( “transactions” )
.eq( “userId” , dealershipOwnerUserIds[userIdCounter]).eq( “transactionType” , “Carplan” )
.eq( “transStatus” , “Pending” )
)
.ascending( “transId” )
.limit( 1000 )
.find();
//console.log("Number of transaction results: " + transactions_userId_results.items.length);
for ( let x in transactions_userId_results.items) {
transactions.push(transactions_userId_results.items[x]);
}
}
$w( “#TransactionsMessagesText” ).text = “Loading all transactions…;”
$w( “#TransactionsProgressBar” ).value = 80 ;
//console.log("Number of transactions: " + transactions.length);

//Step 6 load the transactions into the table
let CarPlanTransactionTableRows = [];
for ( let transactionCounter = 0 ; transactionCounter < transactions.length; transactionCounter++) {
CarPlanTransactionTableRows.push(
{
“transDescription” : transactions[transactionCounter].transDescription,
“transStatus” : transactions[transactionCounter].transStatus,
“transReferralCode” : transactions[transactionCounter].transReferralCode,
“transDate” : transactions[transactionCounter].transDate,
“transCost” : transactions[transactionCounter].transCost,
“transactionType” : transactions[transactionCounter].transactionType
});
}
$w( “#CarPlanTransactionsTable” ).rows = CarPlanTransactionTableRows;
$w( “#TransactionsMessagesText” ).text = “Transactions loaded successfully.”
$w( “#TransactionsProgressBar” ).value = 100 ;

    setTimeout(clearUserDetailsMessages => { 
        $w( "#TransactionsMessagesText" ).text =  "" ; 
        $w( "#TransactionsProgressBar" ).value =  0 ; 
    },  4500 ); 
}  **catch**  (err) { 
    $w( "#TransactionsMessagesText" ).text =  "Error fetching transactions refetching them now." ; 
    setTimeout(clearUserDetailsMessages => { 
        $w( "#TransactionsMessagesText" ).text =  "" ; 
        $w( "#TransactionsProgressBar" ).value =  0 ; 
        loadTransactionsTable(); 
    },  4500 ); 
} 

}

All of my code also runs fine in the editor and this is not the only page where I’m experiencing this problem. It is now at a point where even though Wix is awesome to use I’m considering leaving Wix and warning ever everyone I came in contact with not to use Wix, as random issue show their head frequently. Wix is an awesome platform most of the time but it can be troublesome to use it when stuff like this happens.