-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Please make it possible to get response headers for query directly🙏 #538
Comments
Internal ticket number is OSS-917 |
Based on idea from this Fauna forum issue, I managed to incorporate this solution by overriding faunadb.Client class: class ObserverClient extends faunadb.Client {
constructor(opts) {
super({
...opts,
// overrides observer to save last response
observer: (res) => {
this._lastResponse = res
opts.observer && opts.observer(res) // in case we have custom observer passed.
},
})
this._lastResponse = null
}
async query(expr, options = {}) {
const { returnResponse, ...rest } = options
const result = await super.query(expr, rest)
return returnResponse ? { result, response: this._lastResponse } : result
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Now it is possible to observe headers with observer function, but it will be much more convenient to simply pass some per-query option like
returnResponse
so that I can get billing headers in my tests and write a test suite to calculate projected cost of my app.Currently,
client.query(...)
returns query result only. Desired feature will work like this:I firmly believe this feature will benefit all Faunadb community.
The text was updated successfully, but these errors were encountered: