Skip to content

Commit dcf0d2d

Browse files
replacing callbacks with async/await internally #148; refactoring; making sure all static data is cleared when request is done
1 parent 85e99e1 commit dcf0d2d

19 files changed

+1545
-1888
lines changed

README.md

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Browser-compiled script and type definitions can be found in [dist](/dist/) fold
2222
- **CRUD operations**. Including Fetch XML, Actions and Functions in Microsoft Dataverse Web API.
2323
- **Table Definitions (Entity Metadata)**. Query and modify Table, Column, Choice (Option Set) and Relationship definitions.
2424
- **File Fields**. Upload, Download and Delete data stored in the File Fields.
25-
- **Abort Signal using the Abort Controller** (Browser and Node.js 15+). Abort requests when they are no longer need to be completed. For example: when the user leaves a page without waiting for the data to load.
25+
- **Abort Signal and Abort Controller** (Browser and Node.js 15+). Abort requests when they are no longer need to be completed.
2626
- **Node.js and a Browser** support.
2727
- **Proxy Configuration** support.
2828

@@ -72,25 +72,25 @@ Also, please check [suggestions and contributions](#contributions) section to le
7272
* [Execute Web API actions](#execute-web-api-actions)
7373
* [Execute Batch Operations](#execute-batch-operations)
7474
* [Work with Table Definitions (Entity Metadata)](#work-with-table-definitions-entity-metadata)
75-
* TABLES
75+
* Tables
7676
* [Create a new Table Definition](#create-a-new-table-definition)
7777
* [Retrieve Table Definitions](#retrieve-table-definitions)
7878
* [Update Table Definitions](#update-table-definitions)
7979
* [Retrieve Multiple Table Definitions](#retrieve-multiple-table-definitions)
80-
* COLUMNS
80+
* Columns
8181
* [Create Columns](#create-columns)
8282
* [Retrieve Columns](#retrieve-columns)
8383
* [Update Columns](#update-columns)
8484
* [Retrieve Multiple Columns](#retrieve-multiple-columns)
8585
* [Use requests to query Table and Column definitions](#use-requests-to-query-table-and-column-definitions)
86-
* RELATIONSHIPS
86+
* Relationships
8787
* [Create Relationship](#create-relationship)
8888
* [Update Relationship](#update-relationship)
8989
* [Delete Relationship](#delete-relationship)
9090
* [Retrieve Relationship](#retrieve-relationship)
9191
* [Retrieve Multiple Relationships](#retrieve-multiple-relationships)
9292
* [Use multi-table lookup columns (Polymorfic Lookup Attributes)](#use-multi-table-lookup-columns-polymorfic-lookup-attributes)
93-
* GLOBAL OPTION SETS (CHOICES)
93+
* Global Option Sets (Choices)
9494
* [Create Global Option Set](#create-global-option-set)
9595
* [Update Global Option Set](#update-global-option-set)
9696
* [Delete Global Option Set](#delete-global-option-set)
@@ -174,15 +174,20 @@ const cca = new MSAL.ConfidentialClientApplication(msalConfig);
174174
const serverUrl = 'https://<YOUR ORG HERE>.api.crm.dynamics.com';
175175

176176
//function that acquires a token and passes it to DynamicsWebApi
177-
const acquireToken = (dynamicsWebApiCallback) => {
178-
cca.acquireTokenByClientCredential({
179-
scopes: [`${serverUrl}/.default`],
180-
}).then(response => {
181-
//call DynamicsWebApi callback only when a token has been retrieved successfully
182-
dynamicsWebApiCallback(response.accessToken);
183-
}).catch((error) => {
184-
console.log(error);
185-
});
177+
const acquireToken = async () => {
178+
try {
179+
return cca.acquireTokenByClientCredential({
180+
scopes: [`${serverUrl}/.default`],
181+
});
182+
}
183+
catch (error) {
184+
//error logging here
185+
//or a fallback authentication
186+
187+
//to abort a request just return null
188+
//or re-throw an error
189+
return null;
190+
}
186191
}
187192

188193
//create DynamicsWebApi

0 commit comments

Comments
 (0)