Last active
December 14, 2022 00:26
-
-
Save mllvzeth/f1fc8ce20bb56505cda9c99c6189f85d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/**************************************************************** | |
const createNewCommunity = async (communityName, indigenousAffiliation) => { | |
try { | |
const request_variables = { | |
entity: 'community', | |
field_values: { | |
community_field0: communityName, | |
community_field2: indigenousAffiliation, | |
}, | |
"forceAsyncPostCreateProcessing": true | |
}; | |
const full_response_data = await context.freeagent.createEntity( | |
request_variables | |
); | |
if (full_response_data.length === 0){ | |
return { | |
response: { | |
data: {}, | |
statusText: 'Internal Server Error', | |
status: 500, | |
message: 'Error creating new community', | |
debug: { | |
request_variables, | |
full_response_data, | |
}, | |
}, | |
}; | |
} | |
return { | |
response: { | |
data: full_response_data[0].data.createEntity.entity_value, | |
statusText: 'OK', | |
status: 200, | |
message: 'New community created', | |
debug: { | |
request_variables, | |
full_response_data, | |
}, | |
}, | |
}; | |
} catch (e) { | |
return { | |
response: { | |
data: {}, | |
statusText: e.name, | |
status: 500, | |
message: | |
'Error creating new community' + '\n' + e.message + ' ' + e.stack, | |
}, | |
}; | |
} | |
}; | |
****************************************************************/ | |
[ | |
{ | |
"data": { | |
"createEntity": { | |
"entity_value": { | |
"__typename": "entityValue", | |
"id": "c75459e5-118d-4100-9a94-3b1a930767ad", | |
"cache_key": "list_0_c75459e5-118d-4100-9a94-3b1a930767ad", | |
"seq_id": "COM101783", | |
"field_values": null, | |
"oldestDueTask": null, | |
"is_editable": null, | |
"is_deletable": null, | |
"lines": null | |
}, | |
"__typename": "createEntity" | |
} | |
} | |
} | |
] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment