Hi all,
I'm trying to create a svelte hook to use livepreview within my svelte app. I managed to get the subscription function to work, now every time when I update the page within Payload the mergedData logs to the console. This is working fine, somehow the mergedData contains the none-updated data, even when I'm updating the data and mergedData gets logged to the console it shows the none-updated data within the mergedData object. Clicking the save button within the CMS will update the data to the actual state.
I'm trying to figure out where the problem could be. This is my onChange function and subscription method.
const onChange = (mergedData) => {
console.log(mergedData, 'mergedData');
data.set(mergedData);
isLoading.set(false);
};
const subscription = subscribe({
callback: onChange,
depth,
initialData,
serverURL
});
payload version: 2.0.0
node: v19.9.0
Using the PostgresSQL connection
Fixed it, I was passing in the wrong server URL in the frontend. Should just be the payload server url. In my case:
http://localhost:3000Star
Discord
online
Get dedicated engineering support directly from the Payload team.