@@ -34,8 +34,9 @@ import Data.Function.Uncurried (Fn2, runFn2)
34
34
import Data.HTTP.Method (Method (..), CustomMethod )
35
35
import Data.HTTP.Method as Method
36
36
import Data.List.NonEmpty as NEL
37
- import Data.Maybe (Maybe (..))
37
+ import Data.Maybe (Maybe (..), fromMaybe )
38
38
import Data.Nullable (Nullable , toNullable )
39
+ import Data.Time.Duration (Milliseconds (..))
39
40
import Effect.Aff (Aff , try )
40
41
import Effect.Aff.Compat as AC
41
42
import Effect.Exception as Exn
@@ -56,6 +57,7 @@ type Request a =
56
57
, password :: Maybe String
57
58
, withCredentials :: Boolean
58
59
, responseFormat :: ResponseFormat.ResponseFormat a
60
+ , timeout :: Maybe Milliseconds
59
61
}
60
62
61
63
-- | A record of the type `Request` that has all fields set to default
@@ -79,6 +81,7 @@ defaultRequest =
79
81
, password: Nothing
80
82
, withCredentials: false
81
83
, responseFormat: ResponseFormat .ignore
84
+ , timeout: Nothing
82
85
}
83
86
84
87
-- | The possible errors that can occur when making an Affjax request.
@@ -197,6 +200,7 @@ request req =
197
200
, username: toNullable req.username
198
201
, password: toNullable req.password
199
202
, withCredentials: req.withCredentials
203
+ , timeout: fromMaybe 0.0 $ (\(Milliseconds x) -> x) <$> req.timeout
200
204
}
201
205
202
206
extractContent :: RequestBody.RequestBody -> Either String Foreign
@@ -251,6 +255,7 @@ type AjaxRequest a =
251
255
, username :: Nullable String
252
256
, password :: Nullable String
253
257
, withCredentials :: Boolean
258
+ , timeout :: Number
254
259
}
255
260
256
261
foreign import _ajax
0 commit comments