From 48dfce9695c0fa7b8400f39a893150c7146105bf Mon Sep 17 00:00:00 2001 From: Nicola Squartini Date: Tue, 22 Oct 2024 16:31:11 +0200 Subject: [PATCH] fix: remove unnecessary fields in PATCH Elements in the codeHosting array contain fields such as `createdAt` and `updatedAt`. --- src/register-fast-onboarding.js | 5 ++++- src/registered.js | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/register-fast-onboarding.js b/src/register-fast-onboarding.js index 1dffbcd..285cee0 100644 --- a/src/register-fast-onboarding.js +++ b/src/register-fast-onboarding.js @@ -127,9 +127,12 @@ async function createPublisher(apiURL, pasetoApiToken, pec, amministrazione, ipa } async function updateExistingPublisher(apiURL, pasetoApiToken, publisherID, pec, url, codeHosting) { + // Clean up the codeHosting array by leaving only the url field of each element. + const cleanCodeHosting = codeHosting.map(({ url })=> ({ url })); + const apiPayload = { email: pec, - codeHosting: [ ...codeHosting, { url } ], + codeHosting: [ ...cleanCodeHosting, { url } ], }; const res = await fetch(`${apiURL}/publishers/${publisherID}`, { diff --git a/src/registered.js b/src/registered.js index 1edd731..18d125f 100644 --- a/src/registered.js +++ b/src/registered.js @@ -129,9 +129,12 @@ async function createPublisher(apiURL, pasetoApiToken, pec, amministrazione, ipa } async function updateExistingPublisher(apiURL, pasetoApiToken, publisherID, pec, url, codeHosting) { + // Clean up the codeHosting array by leaving only the url field of each element. + const cleanCodeHosting = codeHosting.map(({ url })=> ({ url })); + const apiPayload = { email: pec, - codeHosting: [ ...codeHosting, { url } ], + codeHosting: [ ...cleanCodeHosting, { url } ], }; const res = await fetch(`${apiURL}/publishers/${publisherID}`, {