Hi,
I have a server-side action and I need it to do the following:
- Call a third party API, retrieve a list of all projects, and identify if my project already exists.
- If my project exists, use its internal ID from the API response in subsequent actions.
- If the project doesn’t exist, create it with another API call, and use the returned internal ID in the subsequent actions instead.
If it’s easier to understand in pseudocode:
const myProject = “My Project”;
var projects = listProjectsApiCall();
var internalId;
projects.forEach((project) => {
if (project.name == myProject) {
internalId = project.id;
}
});
if (!internalId) {
internalId = createProjectApiCall(myProject);
}
// do more stuff with internalId
I can see how to achieve this with plugins but I feel there ought to be a “Bubble” way to do it that I can’t figure out… any ideas?
Thanks!