In my datasource, I currently need access to the headers of the response.
To do that I added a protected method didReceiveResponse like didReceiveErrorResponse in the RESTDataSource class. I can then overwrite this method in an implementation of a RESTDataSource class where I need access to the headers (e.g to return the link in the headers).
export class MovieAPI extends RESTDataSource {
...
protected async didReceiveResponse(response) {
const headersLink = response.headers.get("link")
const body = await response.json()
return { body, headersLink: headersLink }
}
...
public async getMovies(): Promise<String[]> {
const { body, headersLink } = this.get(`movies`)
// do something with headers link
...
retrun body
}
...
}
I have created a PR to add this method to RESTDataSource.ts (PR #1325)
PR merged
Are there docs on how to use this functionality? I am not able to get it to work as the explanation above leads me to believe
Most helpful comment
Are there docs on how to use this functionality? I am not able to get it to work as the explanation above leads me to believe