Skip to content

Commit 83bf9b6

Browse files
Add separate file for ResponseTypes, Update Readme to guide setting different ResponseTypes
1 parent 20fa494 commit 83bf9b6

17 files changed

+86
-51
lines changed

README.md

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,19 @@ You can pass in additional request headers, either individually or in a dictiona
241241
````
242242

243243
### .responseType()
244-
To set a custom response type, use the `.responseType(string)` method. To see an example, check the [browser sample](samples/browser/index.html) that downloads an image and displays it in an `<img>` element.
244+
To set a custom response type, use the `.responseType(<ResponseType>)` method. Refer [ResponseType.ts](./src/ResponseType.ts) for available options.
245+
````js
246+
client
247+
.api(`/me/drive/root/children/${fileName}/content`)
248+
.responseType(MicrosoftGraph.ResponseType.BLOB)
249+
.get()
250+
.then((res) => {
251+
console.log("Downloaded..!!");
252+
})
253+
.catch((err) => {
254+
throw err;
255+
});
256+
````
245257

246258
## Running node samples
247259
You can run and debug the node samples found under [./samples/node/node-sample.js](./samples/node/node-sample.js) by running the *Run node samples* configuration from the **Debug** (Ctrl + Shift + D) menu in Visual Studio Code. Alternately, you can run the node samples from the CLI by entering `node ./samples/node/node-sample.js` (assuming you are at the root of this repo). You'll need to rename the *secrets.example.json* file to *secrets.json* and add a valid access token to it. You can get an access token by doing the following:
@@ -313,28 +325,6 @@ We'd love to get your feedback about the Microsoft Graph JavaScript client libra
313325

314326
## Contributing
315327
Please see the [contributing guidelines](CONTRIBUTING.md).
316-
## Changelog
317-
318-
#### 1.0.0
319-
* Added tests for new Graph functionality - Delta query, Extensibility, OneNote, and more.
320-
321-
#### 0.4.0
322-
* Add support for ES5. Make sure to use `graph-js-sdk-web.js` for web apps
323-
* Removed iterator helper method.
324-
325-
#### 0.3.1
326-
* Support for Node.js versions 4 and 5
327-
328-
#### 0.3.0
329-
* Migrated away from typings in client library core and TypeScript sample
330-
331-
#### 0.2.2
332-
* Updated SuperAgent to version ``` 3.3.0 ```
333-
334-
#### 0.2.0
335-
* **Breaking change for existing apps** - Initialize the client library with `MicrosoftGraph.Client.init({...})`. See the updated usage section below for code samples.
336-
* Added response handling tests to simulate Graph calls
337-
* Added type declarations file for core client library, which adds intellisense for chained methods.
338328

339329

340330
## Additional resources

lib/graph-js-sdk-web.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/GraphRequest.js

Lines changed: 11 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/GraphRequest.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/ResponseType.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export declare enum ResponseType {
2+
ARRAYBUFFER = "arraybuffer",
3+
BLOB = "blob",
4+
DOCUMENT = "document",
5+
JSON = "json",
6+
STREAM = "stream",
7+
TEXT = "text"
8+
}

lib/src/ResponseType.js

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/ResponseType.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/common.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export declare let oDataQueryNames: string[];
22
export declare const DEFAULT_VERSION = "v1.0";
33
export declare const GRAPH_BASE_URL = "https://graph.microsoft.com/";
4-
export declare const PACKAGE_VERSION = "1.0.0";
4+
export declare const PACKAGE_VERSION = "1.1.0";
55
export interface AuthProviderCallback {
66
(error: any, accessToken: string): void;
77
}

lib/src/common.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ export declare class Client {
88
export * from "./GraphRequest";
99
export * from "./common";
1010
export * from "./ResponseHandler";
11+
export * from "./ResponseType";

0 commit comments

Comments
 (0)