Do you want to request a feature or report a bug?
>
I have a question.
Is it possible to configure http timeout for the lib.
Smth like httpOptions: {timeout: 500}?
@ryaa do you mean for the API calls or S3 / Storage ?
API calls.. For example for Auth.signIn method call
what is the default timeout for API calls? such as API.get()
+1 for this task- looking at the source code i can't see a way to add or set the TIMEOUT.
+1 for this task- looking at the source code i can't see a way to add or set the TIMEOUT.
For reference to anyone looking to set the timeout or any other configuration option prior to sending a request- use an AXIOS request interceptor:
import axios from "axios";
axios.interceptors.request.use((config) => {
config.timeout = 5000;
});
Hi,
Any update on this?
I don't find any information in the docs =/
and @JohnnyMinty solution doesn't seems to work.
Any news on that ?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Bump
I've attempted to add timeout support for API calls, eg API.[get/post/put/patch/del/head].
Usage is like so:
let params = {
timeout: 2500 // OPTIONAL
};
API.get('apiName', '/path', params);
It sounds like some people here also wanted a timeout option for the Auth library, but that's a bit beyond my current understanding of Amplify and beyond my use case so someone else more appropriate should tackle that.
Cheers
In case the feature is rejected, or if you need a solution right now you can also set a timeout by changing the default timeout of axios.
Put this code somewhere in your codebase to change Axios' default timeout
const axios = require('axios');
axios.defaults.timeout = 2500; // 2.5 seconds etc
Hello, I found that the proposed solution from @JohnnyMinty is working for me but with some slight changes. To be more precise, what has worked in my RN project is:
import axios from 'axios';
axios.interceptors.request.use((config) => {
config.timeout = 5000;
return config;
}, (error) => {
return Promise.reject(error);
});
Hope this helps more people and that features like this get integrated in the library itself in the future!
But that is global settings, but we need a single config for every Api.get().
I think it will be a good choice if we could set all params to axios by API/RestClient in aws lib.
I also find that this feature would be very useful.
Are there any news about this?
Most helpful comment
For reference to anyone looking to set the timeout or any other configuration option prior to sending a request- use an AXIOS request interceptor:
import axios from "axios";
axios.interceptors.request.use((config) => {
config.timeout = 5000;
});