mirror of
https://github.com/janishutz/oidc-login-sdk.git
synced 2026-10-08 17:36:20 +02:00
feat: better error handling
This commit is contained in:
1 parent
bc898d6f0f
commit
d1df43c57a
3 files changed
+29
-17
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@janishutz/oidc-login-sdk-browser",
|
||||
"version": "1.3.5",
|
||||
"version": "1.4.0",
|
||||
"description": "SDK to communicate with and log into a backend running express-openid-connect",
|
||||
"homepage": "https://github.com/janishutz/oidc-login-sdk#readme",
|
||||
"bugs": {
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ export const check = async (): Promise<boolean> => {
|
||||
if ( e instanceof AuthError ) {
|
||||
status = false;
|
||||
} else {
|
||||
throw e;
|
||||
throw await e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+27
-15
@@ -17,9 +17,13 @@ export class UnownedError extends Error {}
|
||||
* @returns The reponse
|
||||
*/
|
||||
export const get = async ( url: string, authErrorResolution?: AuthErrorResolution ): Promise<Response> => {
|
||||
return await wrapper( url, {
|
||||
'credentials': 'include'
|
||||
}, authErrorResolution );
|
||||
try {
|
||||
return await wrapper( url, {
|
||||
'credentials': 'include'
|
||||
}, authErrorResolution );
|
||||
} catch ( e ) {
|
||||
throw await e;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -31,14 +35,18 @@ export const get = async ( url: string, authErrorResolution?: AuthErrorResolutio
|
||||
* @returns The response
|
||||
*/
|
||||
export const post = async ( url: string, payload: string, mime: string = 'application/json', authErrorResolution?: AuthErrorResolution ): Promise<Response> => {
|
||||
return await wrapper( url, {
|
||||
'credentials': 'include',
|
||||
'body': payload,
|
||||
'method': 'post',
|
||||
'headers': {
|
||||
'Content-Type': mime ?? 'application/json'
|
||||
}
|
||||
}, authErrorResolution );
|
||||
try {
|
||||
return await wrapper( url, {
|
||||
'credentials': 'include',
|
||||
'body': payload,
|
||||
'method': 'post',
|
||||
'headers': {
|
||||
'Content-Type': mime ?? 'application/json'
|
||||
}
|
||||
}, authErrorResolution );
|
||||
} catch ( e ) {
|
||||
throw await e;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -48,10 +56,14 @@ export const post = async ( url: string, payload: string, mime: string = 'applic
|
||||
* @returns The response
|
||||
*/
|
||||
export const deleteRequest = async ( url: string, authErrorResolution?: AuthErrorResolution ): Promise<Response> => {
|
||||
return await wrapper( url, {
|
||||
'credentials': 'include',
|
||||
'method': 'delete'
|
||||
}, authErrorResolution );
|
||||
try {
|
||||
return await wrapper( url, {
|
||||
'credentials': 'include',
|
||||
'method': 'delete'
|
||||
}, authErrorResolution );
|
||||
} catch ( e ) {
|
||||
throw await e;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user