Clean up and fixes
This commit is contained in:
@@ -58,10 +58,15 @@ export class SyncServer extends EventEmitter<SyncServerEventMap> {
|
||||
* @param identifier - The invitation identifier.
|
||||
* @returns The invitation.
|
||||
*/
|
||||
async getInvitation(identifier: string): Promise<XOInvitation> {
|
||||
async getInvitation(identifier: string): Promise<XOInvitation | undefined> {
|
||||
// Send a GET request to the sync server
|
||||
const response = await fetch(`${this.baseUrl}/invitations/${identifier}`);
|
||||
const invitation = await response.json() as XOInvitation;
|
||||
const response = await fetch(`${this.baseUrl}/invitations?invitationIdentifier=${identifier}`);
|
||||
|
||||
if(!response.ok) {
|
||||
throw new Error(`Failed to get invitation: ${response.statusText}`);
|
||||
}
|
||||
|
||||
const invitation = await response.json() as XOInvitation | undefined;
|
||||
return invitation;
|
||||
}
|
||||
|
||||
@@ -75,6 +80,9 @@ export class SyncServer extends EventEmitter<SyncServerEventMap> {
|
||||
const response = await fetch(`${this.baseUrl}/invitations`, {
|
||||
method: 'POST',
|
||||
body: encodeExtendedJson(invitation),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
});
|
||||
|
||||
// Throw is there was an issue with the request
|
||||
|
||||
Reference in New Issue
Block a user