You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here's your code reformatted to make it easier for people to follow and help:
asyncfunctionmySync(){try{awaitsynchronize({
database,pullChanges: async({ schemaVersion, lastPulledAt, migration })=>{consturlParams=`last_pulled_at=${lastPulledAt}&schema_version=${schemaVersion}&migration=${encodeURIComponent(JSON.stringify(migration))}`constresponse=awaitAPI.get(`master_sector/sync?${urlParams}`);// Check if the request was successfulif(response.status_code!==200){thrownewError(`Request failed with status ${response.status}`);}consttimestamp=dayjs().unix();return{changes: response.data,timestamp: timestamp};},});}catch(error){console.log("Catch Mysync",error);}}
Also, since you added console.log() statements to it, would you mind sharing what they output? It would also make it easier for others to follow and help.
const timestamp = dayjs().unix(); will always return 1970 jan. You get what you set. If you need current timestamp try to think about dayjs().valueOf()
async function mySync() {
try {
await synchronize({
database,
pullChanges: async ({ schemaVersion, lastPulledAt, migration }) => {
const urlParams =
last_pulled_at=${lastPulledAt}&schema_version=${schemaVersion}&migration=${encodeURIComponent( JSON.stringify(migration), )}
console.log("URL Params", urlParams);
const response = await API.get(
master_sector/sync?${urlParams}
);console.log(response);
// Check if the request was successful
if (response.status_code !== 200) {
throw new Error(
Request failed with status ${response.status}
);}
const timestamp = dayjs().unix();
console.log("timestamp", timestamp);
return { changes: response.data, timestamp: timestamp };
},
}
the timestamp value not read properly. the value 01/jan/1970
any idea?
The text was updated successfully, but these errors were encountered: