aws-amplify / amplify-swift

A declarative library for application development using cloud services.
Apache License 2.0
459 stars 198 forks source link

Header Fields in API Response #3285

Open wolf-mptechnology opened 1 year ago

wolf-mptechnology commented 1 year ago

Is your feature request related to a problem? Please describe.

We need to fetch the eTag header to implement our own caching. On Android this is already possible, on iOS we only get the data.

Describe the solution you'd like

The access should be similar to the Android version:

let response = try await Amplify.API.get(request: request)
let etag = response.headers["etag"]

Describe alternatives you've considered

It seems there is no way to access response headers at all or it is unclear from the documentation: https://docs.amplify.aws/lib/restapi/fetch/q/platform/ios/#get-requests

Is the feature request related to any of the existing Amplify categories?

API

Additional context

No response

github-actions[bot] commented 1 year ago

This has been identified as a feature request. If this feature is important to you, we strongly encourage you to give a 👍 reaction on the request. This helps us prioritize new features most important to you. Thank you!

thisisabhash commented 1 year ago

Thank you for posting this feature request. Our team will post an update on this ticket.

atierian commented 11 months ago

An option to explore here is creating overloads for each of the methods (get / put / post / delete / head / patch) with the @_disfavoredOverload annotation to prevent breaking due to ambiguity of overloaded return types.

// exists today - `RESTTask.Success` is a typealias for `Data`.
func get(request: RESTRequest) async throws -> RESTTask.Success

// new overload -- where `NewReturnType` encapsulates the additional information.
@_disfavoredOverload
func get(request: RESTRequest) async throws -> NewReturnType

The existing method that returns Data would likely be removed in the next major version of the library.

viru-rathore commented 7 months ago

if some information returned as header like session id, which is not available when access response headers. How can i access response header fields.

viru-rathore commented 7 months ago

I am facing this issue with NodeJS library of amplify.

lawmicha commented 7 months ago

Hi @viru-rathore, are you using this library? https://github.com/aws-amplify/amplify-js If so, please open an issue over there with more details

SurajBastola-BO commented 1 day ago

Thank you for posting this feature request. Our team will post an update on this ticket.

Hi, has any update been shared on this request? I'm running into the same issue where we need to get the etag from response headers on a 200 response but I am not able to find any documentation on how this can be achieved. Thanks.