@@ -2,7 +2,7 @@ import axios, { AxiosError } from "axios";
22import { delay , State } from "./index" ;
33
44/**
5- * Handles a unit manifest.
5+ * Handles a unit manifest and returns its actual ID .
66 * @param state {State} - is the application's state.
77 * @param id {string} - is the friendly name of the unit.
88 * @param name {string} - is the display name of the unit.
@@ -16,7 +16,7 @@ export async function handleUnit(
1616 string ,
1717 { next : string [ ] ; previous : string [ ] ; requireAll ?: boolean }
1818 > ,
19- ) : Promise < void > {
19+ ) : Promise < string > {
2020 // First, we need to figure out what the actual ID of our unit is.
2121 // If there isn't one, we'll just set it to null.
2222 const actualID : string | null = await axios
@@ -71,7 +71,7 @@ export async function handleUnit(
7171 }
7272
7373 // Create or update the unit.
74- await axios . put (
74+ const unitID = await axios . put (
7575 "https://cratecode.com/internal/api/unit" ,
7676 {
7777 id : actualID ,
@@ -84,8 +84,11 @@ export async function handleUnit(
8484 authorization : state . key ,
8585 } ,
8686 } ,
87- ) ;
87+ ) . then ( ( res ) => res . data . id as string ) ;
8888 await delay ( state ) ;
89+
90+ // And finally, return the unit ID.
91+ return unitID ;
8992}
9093
9194/**
0 commit comments