1- /*
2- * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license.
3- * See LICENSE in the project root for license information.
4- */
5-
61import https from 'https' ;
72
83const host = 'graph.microsoft.com' ;
@@ -28,24 +23,18 @@ export function postData(path, token, data, callback) {
2823
2924 const req = https . request ( options , res => {
3025 let subscriptionData = '' ;
31- res . on ( 'data' , chunk => {
32- subscriptionData += chunk ;
33- } ) ;
26+
27+ res . on ( 'data' , chunk => ( subscriptionData += chunk ) ) ;
3428 res . on ( 'end' , ( ) => {
35- if ( res . statusCode === 201 ) {
36- callback ( null , JSON . parse ( subscriptionData ) ) ;
37- } else {
38- callback ( JSON . parse ( subscriptionData ) , null ) ;
39- }
29+ if ( res . statusCode === 201 ) callback ( null , JSON . parse ( subscriptionData ) ) ;
30+ else callback ( JSON . parse ( subscriptionData ) , null ) ;
4031 } ) ;
4132 } ) ;
4233
4334 req . write ( data ) ;
4435 req . end ( ) ;
4536
46- req . on ( 'error' , error => {
47- callback ( error , null ) ;
48- } ) ;
37+ req . on ( 'error' , error => callback ( error , null ) ) ;
4938}
5039
5140/**
@@ -69,24 +58,18 @@ export function getData(path, token, callback) {
6958
7059 const req = https . request ( options , res => {
7160 let endpointData = '' ;
72- res . on ( 'data' , chunk => {
73- endpointData += chunk ;
74- } ) ;
61+
62+ res . on ( 'data' , chunk => ( endpointData += chunk ) ) ;
7563 res . on ( 'end' , ( ) => {
76- if ( res . statusCode === 200 ) {
77- callback ( null , JSON . parse ( endpointData ) ) ;
78- } else {
79- callback ( JSON . parse ( endpointData ) , null ) ;
80- }
64+ if ( res . statusCode === 200 ) callback ( null , JSON . parse ( endpointData ) ) ;
65+ else callback ( JSON . parse ( endpointData ) , null ) ;
8166 } ) ;
8267 } ) ;
8368
8469 req . write ( '' ) ;
8570 req . end ( ) ;
8671
87- req . on ( 'error' , error => {
88- callback ( error , null ) ;
89- } ) ;
72+ req . on ( 'error' , error => callback ( error , null ) ) ;
9073}
9174
9275/**
@@ -109,17 +92,11 @@ export function deleteData(path, token, callback) {
10992
11093 const req = https . request ( options , res => {
11194 let endpointData = '' ;
112- res . on ( 'data' , chunk => {
113- endpointData += chunk ;
114- } ) ;
115- res . on ( 'end' , ( ) => {
116- callback ( null ) ;
117- } ) ;
95+ res . on ( 'data' , chunk => ( endpointData += chunk ) ) ;
96+ res . on ( 'end' , ( ) => callback ( null ) ) ;
11897 } ) ;
11998
12099 req . end ( ) ;
121100
122- req . on ( 'error' , error => {
123- callback ( error ) ;
124- } ) ;
101+ req . on ( 'error' , error => callback ( error ) ) ;
125102}
0 commit comments