{"id":3300,"date":"2019-08-28T18:58:48","date_gmt":"2019-08-29T01:58:48","guid":{"rendered":"https:\/\/developer.microsoft.com\/en-us\/office\/blogs\/?p=3300"},"modified":"2019-08-28T18:58:48","modified_gmt":"2019-08-29T01:58:48","slug":"microsoft-graph-sdk-for-javascript-2-0-0","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/microsoft-graph-sdk-for-javascript-2-0-0\/","title":{"rendered":"Microsoft Graph SDK for JavaScript &#8211; 2.0.0"},"content":{"rendered":"<p>We are excited to announce a new <a href=\"https:\/\/github.com\/microsoftgraph\/msgraph-sdk-javascript\/releases\/tag\/2.0.0\">release<\/a> of our JavaScript SDK 2.0.0 for Microsoft Graph. The version is updated to 2.0.0 because it contains a number of breaking changes. However, making the necessary changes to adopt this version should not be significant. More details can be found in our <a href=\"https:\/\/github.com\/microsoftgraph\/msgraph-sdk-javascript\/wiki\/Migration-from-1.x.x-to-2.x.x\">migration guide<\/a>.<\/p>\n<h3>Removed polyfills<\/h3>\n<p>In the past our library has included polyfills for <code>fetch<\/code> and <code>promise<\/code>. However, doing so adds to the size of our library and many of our customers do not need these polyfills due to their target platform or the fact they already include them in their application. We have now removed the polyfills for <code>fetch<\/code> and <code>promise<\/code>. Developers who do still need the polyfills will need to include them explicitly.<\/p>\n<h3>New minified files<\/h3>\n<p>Previously we shipped two different bundles, <code>graph-js-sdk-web.js<\/code> and <code>graph-js-sdk-core.js<\/code>, with and without dependencies bundled. These files are no longer available. Now, a new file named <code>graph-js-sdk.js<\/code> will be shipped for use in any kind of application and can simply be referenced via a script tag. For developers building libraries that want to include the SDK, it is now available as an ES module in the <code>graph-es-sdk.js<\/code> file.<\/p>\n<h3>Getting Raw Response<\/h3>\n<p>In the past, if you wanted to get the raw HTTP response back it was necessary to pass a callback in the get(), put(), post(),etc method. The implementation of this approach was causing issues for node.js applications. To resolve this and provide a more consistent experience, we introduced a new <code>ResponseType<\/code>. Returning raw responses is now as simple as:<\/p>\n<pre><code class=\"language-js\">client\n    .api('\/me')\n    .responseType(ResponseType.RAW)\n    .get((err, rawResponse) =&gt; {\n        console.log(rawResponse);\n    });\n<\/code><\/pre>\n<h3>Changes to the Authentication Provider<\/h3>\n<p>In anticipation for support of more authentication flows, the <code>MSALAuthenticationProvider<\/code> class has been renamed to <code>ImplicitMSALAuthenticationProvider<\/code>.<\/p>\n<p>In order to create an instance of <code>ImplicitMSALAuthenticationProvider<\/code> you now must pass an instance of MSAL&#8217;s <code>UserAgentApplication<\/code> and <code>MSALAuthenticationProviderOptions<\/code>. This brings consistency with the SDKs from other platforms and ensures that an application can have easy access to the <code>UserAgentApplication<\/code> to interact with it directly. Be aware that in the v1.0.0 release of MSAL.js there were breaking changes to the way <code>UserAgentApplication<\/code> is created.<\/p>\n<h3>Default Content-Type for PUT method<\/h3>\n<p>Some users reported confusion when trying to perform PUT calls that would fail due to missing or invalid <code>Content-Type<\/code> header. To minimize these issues we decided to default the <code>Content-Type<\/code> to <code>application\/json<\/code> as this is the most common case. When trying to PUT a payload other than JSON, simply use the <code>.header<\/code> method to change the Content-Type.<\/p>\n<h3>Definitely Typed<\/h3>\n<p>For developers who only need to use the Typescript types for the request and response models we have now published these types to the Definitely Typed repository under the name <code>microsoft-graph<\/code>.<\/p>\n<h3>Feedback<\/h3>\n<p>Thank you to all the community members who continue to provide us feedback on this library. We encourage you to go and upgrade to this new version of our Graph JavaScript API. You can follow these links for installation instructions, <a href=\"https:\/\/github.com\/microsoftgraph\/msgraph-sdk-javascript\/releases\">release notes<\/a> and <a href=\"https:\/\/www.npmjs.com\/package\/@microsoft\/microsoft-graph-client\">npm packages<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We are excited to announce a new <a href=\"https:\/\/github.com\/microsoftgraph\/msgraph-sdk-javascript\/releases\/tag\/2.0.0\">release<\/a> of our JavaScript SDK 2.0.0 for Microsoft Graph.<\/p>\n","protected":false},"author":69114,"featured_media":25159,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-3300","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-microsoft-graph"],"acf":[],"blog_post_summary":"<p>We are excited to announce a new <a href=\"https:\/\/github.com\/microsoftgraph\/msgraph-sdk-javascript\/releases\/tag\/2.0.0\">release<\/a> of our JavaScript SDK 2.0.0 for Microsoft Graph.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts\/3300","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/users\/69114"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/comments?post=3300"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts\/3300\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/media\/25159"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/media?parent=3300"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/categories?post=3300"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/tags?post=3300"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}