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
Possibility to use custom reviver in deserialization? #538
Comments
I see request.js/src/fetch-wrapper.ts Lines 138 to 142 in 5b03156
|
@gr2m I saw how I could supply a custom I found https://stackoverflow.com/questions/45425169/intercept-fetch-api-requests-and-responses-in-javascript on how to create a fetch modification, but the Could you explain how you would see that working? |
I got it now, please ignore my comment, it doesn't resolve your problem. So what you want is in the JSON you receive from GitHub's API, all timestamp strings should be turned into Date objects? You could implement that with a request hook, using Something like this octokit.hook.wrap("request", async (request, options) => {
const response = await request(options);
// TODO: turn all timestamp strings into Date objects in `response`
return response
}); I wonder why you want that though. It feels like a intransparent side effect that you might trip over easily in the future. I'd rather turn the timestamps into Date objects as needed. |
Crosspost from octokit/graphql.js#414 since the request/response logic is done here
Is it possible to use custom revivers in the deserialization, so that
Date
strings could be serialized back directly toDate
objects?See https://stackoverflow.com/a/35923990/1114918 for reference.
Should I maybe do something with a custom
fetch
implementation?The text was updated successfully, but these errors were encountered: