Created
December 30, 2015 20:02
-
-
Save anomaly44/cdaa5e4dbd03e9a8429e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import db from '../db'; | |
export default class Issue { | |
constructor(data) { | |
... | |
} | |
static insertNewIssue(data) { | |
// var value = null; | |
db('issue').insert({ | |
agency_id: data.agencyId, | |
contact_id: 1, | |
tree_problem_id: data.id, | |
address_id: 11, | |
permission_to_access: data.extra.permission === 'true', | |
notes: data.extra.notes, | |
info: 'some info' | |
}).then((res) => { | |
return {success: true, result: res}; | |
}) | |
.catch((error) => { | |
console.log('error inserting new Issue:' + JSON.stringify(error)); | |
return {success: false, result: error}; | |
}); | |
/* console.log(value); | |
return value;*/ | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Issue from '../../models/Issue'; | |
// this is part of an API the new Promise((resolve, reject) => ... is ok and it works | |
export default function submitIssue(req) { | |
return new Promise((resolve,reject) => { | |
const result = Issue.insertNewIssue(req.body); | |
console.log(result); | |
if(result.success) { | |
resolve(result.result); | |
} else { | |
reject(result.result); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment