@@ -28,10 +28,10 @@ const FormData = require('form-data');
2828 * and
2929 * https://cloud.google.com/iap/docs/authentication-howto
3030 *
31- * @param {!Object } event The Cloud Functions event.
31+ * @param {!Object } data The Cloud Functions event data .
3232 * @returns {Promise }
3333 */
34- exports . triggerDag = async event => {
34+ exports . triggerDag = async data => {
3535 // Fill in your Composer environment information here.
3636
3737 // The project that holds your function
@@ -47,7 +47,7 @@ exports.triggerDag = async event => {
4747 // Other constants
4848 const WEBSERVER_URL = `https://${ WEBSERVER_ID } .appspot.com/api/experimental/dags/${ DAG_NAME } /dag_runs` ;
4949 const USER_AGENT = 'gcf-event-trigger' ;
50- const BODY = { conf : JSON . stringify ( event . data ) } ;
50+ const BODY = { conf : JSON . stringify ( data ) } ;
5151
5252 // Make the request
5353 try {
@@ -86,7 +86,7 @@ const authorizeIap = async (clientId, projectId, userAgent) => {
8686 headers : { 'User-Agent' : userAgent , 'Metadata-Flavor' : 'Google' } ,
8787 }
8888 ) ;
89- const tokenResponse = res . json ( ) ;
89+ const tokenResponse = await res . json ( ) ;
9090 if ( tokenResponse . error ) {
9191 return Promise . reject ( tokenResponse . error ) ;
9292 }
@@ -116,7 +116,7 @@ const authorizeIap = async (clientId, projectId, userAgent) => {
116116 } ,
117117 }
118118 ) ;
119- const blobJson = blob . json ( ) ;
119+ const blobJson = await blob . json ( ) ;
120120 if ( blobJson . error ) {
121121 return Promise . reject ( blobJson . error ) ;
122122 }
@@ -132,7 +132,7 @@ const authorizeIap = async (clientId, projectId, userAgent) => {
132132 method : 'POST' ,
133133 body : form ,
134134 } ) ;
135- const tokenJson = token . json ( ) ;
135+ const tokenJson = await token . json ( ) ;
136136 if ( tokenJson . error ) {
137137 return Promise . reject ( tokenJson . error ) ;
138138 }
0 commit comments