Wednesday 24 October 2018

Unhandled rejection Error: Can't set headers after they are sent [help]

I can't figure out where the issue lies...Based on my research of what this error means, It seems like somewhere I am either sending a request twice or sending a response twice. I don't see anywhere this is happening...file1.js export const wrapper = (req, res, next) => { async function getValue(user) { await getExpiration(user).then(response => { if (response.condition) { return res.status(401).json() } }) } getValue(user) } ...file2.js export const getExpiration = async user => { return new Promise((resolve, reject) => { getOrgInfo(user.org_id) .then(res => { return resolve(res) }).catch(err => reject(err)) }).catch(err => console.log(err)) } } ...file3.js // this is a function that talks to my database and returns a promise export const getOrgInfo = (org_id) => { return kx('orgs').select('Expiration').where({'id': org_id}) }

Submitted October 25, 2018 at 01:22AM by chrismellor08

No comments:

Post a Comment