Skip to content

Commit

Permalink
make samples work (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-fenster authored Nov 16, 2017
1 parent 28fdfd2 commit 0aa2cf5
Showing 1 changed file with 8 additions and 24 deletions.
32 changes: 8 additions & 24 deletions samples/tables.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,11 @@ function copyTable(
console.log(`Job ${job.id} started.`);

// Wait for the job to finish
return job.promise();
})
.then(() => {
// Get the job's status
return job.getMetadata();
return job;
})
.then(metadata => {
// Check the job's status for errors
const errors = metadata[0].status.errors;
const errors = metadata.status.errors;
if (errors && errors.length > 0) {
throw errors;
}
Expand Down Expand Up @@ -254,15 +250,11 @@ function importLocalFile(datasetId, tableId, filename, projectId) {
console.log(`Job ${job.id} started.`);

// Wait for the job to finish
return job.promise();
})
.then(() => {
// Get the job's status
return job.getMetadata();
return job;
})
.then(metadata => {
// Check the job's status for errors
const errors = metadata[0].status.errors;
const errors = metadata.status.errors;
if (errors && errors.length > 0) {
throw errors;
}
Expand Down Expand Up @@ -324,15 +316,11 @@ function importFileFromGCS(
console.log(`Job ${job.id} started.`);

// Wait for the job to finish
return job.promise();
})
.then(() => {
// Get the job's status
return job.getMetadata();
return job;
})
.then(metadata => {
// Check the job's status for errors
const errors = metadata[0].status.errors;
const errors = metadata.status.errors;
if (errors && errors.length > 0) {
throw errors;
}
Expand Down Expand Up @@ -388,15 +376,11 @@ function exportTableToGCS(datasetId, tableId, bucketName, filename, projectId) {
console.log(`Job ${job.id} started.`);

// Wait for the job to finish
return job.promise();
})
.then(() => {
// Get the job's status
return job.getMetadata();
return job;
})
.then(metadata => {
// Check the job's status for errors
const errors = metadata[0].status.errors;
const errors = metadata.status.errors;
if (errors && errors.length > 0) {
throw errors;
}
Expand Down

0 comments on commit 0aa2cf5

Please sign in to comment.