UNPKG

28.2 kBHTMLView Raw
1<!DOCTYPE html>
2<html lang="en">
3<head>
4 <meta charset="utf-8">
5 <title>HttpTransportClient - Documentation</title>
6
7 <script src="scripts/prettify/prettify.js"></script>
8 <script src="scripts/prettify/lang-css.js"></script>
9 <!--[if lt IE 9]>
10 <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
11 <![endif]-->
12 <link type="text/css" rel="stylesheet" href="styles/prettify.css">
13 <link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
14 <meta name="viewport" content="width=device-width, initial-scale=1.0">
15</head>
16<body>
17
18<input type="checkbox" id="nav-trigger" class="nav-trigger" />
19<label for="nav-trigger" class="navicon-button x">
20 <div class="navicon"></div>
21</label>
22
23<label for="nav-trigger" class="overlay"></label>
24
25<nav>
26 <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="HttpTransportBuilder.html">HttpTransportBuilder</a><ul class='methods'><li data-type='method'><a href="HttpTransportBuilder.html#createClient">createClient</a></li><li data-type='method'><a href="HttpTransportBuilder.html#retries">retries</a></li><li data-type='method'><a href="HttpTransportBuilder.html#retryDelay">retryDelay</a></li><li data-type='method'><a href="HttpTransportBuilder.html#use">use</a></li><li data-type='method'><a href="HttpTransportBuilder.html#userAgent">userAgent</a></li></ul></li><li><a href="HttpTransportClient.html">HttpTransportClient</a><ul class='methods'><li data-type='method'><a href="HttpTransportClient.html#asBody">asBody</a></li><li data-type='method'><a href="HttpTransportClient.html#asResponse">asResponse</a></li><li data-type='method'><a href="HttpTransportClient.html#delete">delete</a></li><li data-type='method'><a href="HttpTransportClient.html#get">get</a></li><li data-type='method'><a href="HttpTransportClient.html#head">head</a></li><li data-type='method'><a href="HttpTransportClient.html#headers">headers</a></li><li data-type='method'><a href="HttpTransportClient.html#patch">patch</a></li><li data-type='method'><a href="HttpTransportClient.html#post">post</a></li><li data-type='method'><a href="HttpTransportClient.html#put">put</a></li><li data-type='method'><a href="HttpTransportClient.html#query">query</a></li><li data-type='method'><a href="HttpTransportClient.html#retry">retry</a></li><li data-type='method'><a href="HttpTransportClient.html#retryDelay">retryDelay</a></li><li data-type='method'><a href="HttpTransportClient.html#timeout">timeout</a></li><li data-type='method'><a href="HttpTransportClient.html#use">use</a></li></ul></li></ul>
27</nav>
28
29<div id="main">
30
31 <h1 class="page-title">HttpTransportClient</h1>
32
33
34
35
36
37
38
39<section>
40
41<header>
42
43 <h2>
44 HttpTransportClient
45 </h2>
46
47 <div class="class-description"><p>Core client</p></div>
48
49
50</header>
51
52<article>
53 <div class="container-overview">
54
55
56
57
58 <h2>Constructor</h2>
59
60
61 <h4 class="name" id="HttpTransportClient"><span class="type-signature"></span>new HttpTransportClient<span class="signature">(transport, defaults)</span><span class="type-signature"></span></h4>
62
63
64
65
66
67
68<dl class="details">
69
70
71 <dt class="tag-source">Source:</dt>
72 <dd class="tag-source"><ul class="dummy"><li>
73 <a href="client.js.html">client.js</a>, <a href="client.js.html#line9">line 9</a>
74 </li></ul></dd>
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106</dl>
107
108
109
110
111
112<div class="description">
113 <p>Create a HttpTransport.</p>
114</div>
115
116
117
118
119
120
121
122
123
124
125
126 <h5>Parameters:</h5>
127
128
129<table class="params">
130 <thead>
131 <tr>
132
133 <th>Name</th>
134
135
136 <th>Type</th>
137
138
139
140
141
142 <th class="last">Description</th>
143 </tr>
144 </thead>
145
146 <tbody>
147
148
149 <tr>
150
151 <td class="name"><code>transport</code></td>
152
153
154 <td class="type">
155
156
157<span class="param-type">Transport</span>
158
159
160
161 </td>
162
163
164
165
166
167 <td class="description last"><p>Transport instance.</p></td>
168 </tr>
169
170
171
172 <tr>
173
174 <td class="name"><code>defaults</code></td>
175
176
177 <td class="type">
178
179
180<span class="param-type">object</span>
181
182
183
184 </td>
185
186
187
188
189
190 <td class="description last"><p>default configuration</p></td>
191 </tr>
192
193
194 </tbody>
195</table>
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213 </div>
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228 <h3 class="subsection-title">Methods</h3>
229
230
231
232
233
234
235 <h4 class="name" id="asBody"><span class="type-signature">(async) </span>asBody<span class="signature">()</span><span class="type-signature"></span></h4>
236
237
238
239
240
241
242<dl class="details">
243
244
245 <dt class="tag-source">Source:</dt>
246 <dd class="tag-source"><ul class="dummy"><li>
247 <a href="client.js.html">client.js</a>, <a href="client.js.html#line270">line 270</a>
248 </li></ul></dd>
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280</dl>
281
282
283
284
285
286<div class="description">
287 <p>Initiates the request, returning the response body, if successful.</p>
288</div>
289
290
291
292
293
294
295
296
297
298 <h5>Example</h5>
299
300 <pre class="prettyprint"><code>const httpTransport = require('@bbc/http-transport');
301
302const body = await httpTransport.createClient()
303 .asBody();
304
305 console.log(body);</code></pre>
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322<h5>Returns:</h5>
323
324
325<div class="param-desc">
326 <p>a Promise. If the Promise fulfils,
327the fulfilment value is the response body. The body type defaults to string.
328If the content-type response header contains 'json'
329or the json: true option has been set on transport layer
330then the body type will be json.</p>
331</div>
332
333
334
335
336
337
338
339
340
341
342
343 <h4 class="name" id="asResponse"><span class="type-signature">(async) </span>asResponse<span class="signature">()</span><span class="type-signature"></span></h4>
344
345
346
347
348
349
350<dl class="details">
351
352
353 <dt class="tag-source">Source:</dt>
354 <dd class="tag-source"><ul class="dummy"><li>
355 <a href="client.js.html">client.js</a>, <a href="client.js.html#line289">line 289</a>
356 </li></ul></dd>
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388</dl>
389
390
391
392
393
394<div class="description">
395 <p>Initiates the request, returning a http transport response object, if successful.</p>
396</div>
397
398
399
400
401
402
403
404
405
406 <h5>Example</h5>
407
408 <pre class="prettyprint"><code>const httpTransport = require('@bbc/http-transport');
409
410const response = await httpTransport.createClient()
411 .asResponse()
412
413 console.log(response);</code></pre>
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430<h5>Returns:</h5>
431
432
433<div class="param-desc">
434 <p>a Promise. If the Promise fulfils,
435the fulfilment value is response object.</p>
436</div>
437
438
439
440
441
442
443
444
445
446
447
448 <h4 class="name" id="delete"><span class="type-signature"></span>delete<span class="signature">(baseUrl)</span><span class="type-signature"></span></h4>
449
450
451
452
453
454
455<dl class="details">
456
457
458 <dt class="tag-source">Source:</dt>
459 <dd class="tag-source"><ul class="dummy"><li>
460 <a href="client.js.html">client.js</a>, <a href="client.js.html#line112">line 112</a>
461 </li></ul></dd>
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493</dl>
494
495
496
497
498
499<div class="description">
500 <p>Make a HTTP DELETE request</p>
501</div>
502
503
504
505
506
507
508
509
510
511 <h5>Example</h5>
512
513 <pre class="prettyprint"><code>const httpTransport = require('@bbc/http-transport');
514
515const response = await httpTransport.createClient()
516 .delete(baseUrl)
517 .asResponse();</code></pre>
518
519
520
521
522 <h5>Parameters:</h5>
523
524
525<table class="params">
526 <thead>
527 <tr>
528
529 <th>Name</th>
530
531
532 <th>Type</th>
533
534
535
536
537
538 <th class="last">Description</th>
539 </tr>
540 </thead>
541
542 <tbody>
543
544
545 <tr>
546
547 <td class="name"><code>baseUrl</code></td>
548
549
550 <td class="type">
551
552
553<span class="param-type">string</span>
554
555
556
557 </td>
558
559
560
561
562
563 <td class="description last"></td>
564 </tr>
565
566
567 </tbody>
568</table>
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583<h5>Returns:</h5>
584
585
586<div class="param-desc">
587 <p>a HttpTransport instance</p>
588</div>
589
590
591
592
593
594
595
596
597
598
599
600 <h4 class="name" id="get"><span class="type-signature"></span>get<span class="signature">(baseUrl)</span><span class="type-signature"></span></h4>
601
602
603
604
605
606
607<dl class="details">
608
609
610 <dt class="tag-source">Source:</dt>
611 <dd class="tag-source"><ul class="dummy"><li>
612 <a href="client.js.html">client.js</a>, <a href="client.js.html#line53">line 53</a>
613 </li></ul></dd>
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645</dl>
646
647
648
649
650
651<div class="description">
652 <p>Make a HTTP GET request</p>
653</div>
654
655
656
657
658
659
660
661
662
663 <h5>Example</h5>
664
665 <pre class="prettyprint"><code>const httpTransport = require('@bbc/http-transport');
666
667const response = await httpTransport.createClient()
668 .get(url)
669 .asResponse();</code></pre>
670
671
672
673
674 <h5>Parameters:</h5>
675
676
677<table class="params">
678 <thead>
679 <tr>
680
681 <th>Name</th>
682
683
684 <th>Type</th>
685
686
687
688
689
690 <th class="last">Description</th>
691 </tr>
692 </thead>
693
694 <tbody>
695
696
697 <tr>
698
699 <td class="name"><code>baseUrl</code></td>
700
701
702 <td class="type">
703
704
705<span class="param-type">string</span>
706
707
708
709 </td>
710
711
712
713
714
715 <td class="description last"></td>
716 </tr>
717
718
719 </tbody>
720</table>
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735<h5>Returns:</h5>
736
737
738<div class="param-desc">
739 <p>a HttpTransport instance</p>
740</div>
741
742
743
744
745
746
747
748
749
750
751
752 <h4 class="name" id="head"><span class="type-signature"></span>head<span class="signature">(baseUrl)</span><span class="type-signature"></span></h4>
753
754
755
756
757
758
759<dl class="details">
760
761
762 <dt class="tag-source">Source:</dt>
763 <dd class="tag-source"><ul class="dummy"><li>
764 <a href="client.js.html">client.js</a>, <a href="client.js.html#line150">line 150</a>
765 </li></ul></dd>
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797</dl>
798
799
800
801
802
803<div class="description">
804 <p>Make a HTTP HEAD request</p>
805</div>
806
807
808
809
810
811
812
813
814
815 <h5>Example</h5>
816
817 <pre class="prettyprint"><code>const httpTransport = require('@bbc/http-transport');
818
819const response = await httpTransport.createClient()
820 .head(baseUrl)
821 .asResponse();</code></pre>
822
823
824
825
826 <h5>Parameters:</h5>
827
828
829<table class="params">
830 <thead>
831 <tr>
832
833 <th>Name</th>
834
835
836 <th>Type</th>
837
838
839
840
841
842 <th class="last">Description</th>
843 </tr>
844 </thead>
845
846 <tbody>
847
848
849 <tr>
850
851 <td class="name"><code>baseUrl</code></td>
852
853
854 <td class="type">
855
856
857<span class="param-type">string</span>
858
859
860
861 </td>
862
863
864
865
866
867 <td class="description last"></td>
868 </tr>
869
870
871 </tbody>
872</table>
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887<h5>Returns:</h5>
888
889
890<div class="param-desc">
891 <p>a HttpTransport instance</p>
892</div>
893
894
895
896
897
898
899
900
901
902
903
904 <h4 class="name" id="headers"><span class="type-signature"></span>headers<span class="signature">(name, value)</span><span class="type-signature"></span></h4>
905
906
907
908
909
910
911<dl class="details">
912
913
914 <dt class="tag-source">Source:</dt>
915 <dd class="tag-source"><ul class="dummy"><li>
916 <a href="client.js.html">client.js</a>, <a href="client.js.html#line170">line 170</a>
917 </li></ul></dd>
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949</dl>
950
951
952
953
954
955<div class="description">
956 <p>Sets the request headers</p>
957</div>
958
959
960
961
962
963
964
965
966
967 <h5>Example</h5>
968
969 <pre class="prettyprint"><code>const httpTransport = require('@bbc/http-transport');
970
971const response = await httpTransport.createClient()
972 .headers({
973 'User-Agent' : 'someUserAgent'
974 })
975 .asResponse();</code></pre>
976
977
978
979
980 <h5>Parameters:</h5>
981
982
983<table class="params">
984 <thead>
985 <tr>
986
987 <th>Name</th>
988
989
990 <th>Type</th>
991
992
993
994
995
996 <th class="last">Description</th>
997 </tr>
998 </thead>
999
1000 <tbody>
1001
1002
1003 <tr>
1004
1005 <td class="name"><code>name</code></td>
1006
1007
1008 <td class="type">
1009
1010
1011<span class="param-type">string</span>
1012|
1013
1014<span class="param-type">object</span>
1015
1016
1017
1018 </td>
1019
1020
1021
1022
1023
1024 <td class="description last"><p>header name or headers object</p></td>
1025 </tr>
1026
1027
1028
1029 <tr>
1030
1031 <td class="name"><code>value</code></td>
1032
1033
1034 <td class="type">
1035
1036
1037<span class="param-type">string</span>
1038|
1039
1040<span class="param-type">object</span>
1041
1042
1043
1044 </td>
1045
1046
1047
1048
1049
1050 <td class="description last"><p>header value</p></td>
1051 </tr>
1052
1053
1054 </tbody>
1055</table>
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070<h5>Returns:</h5>
1071
1072
1073<div class="param-desc">
1074 <p>a HttpTransport instance</p>
1075</div>
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087 <h4 class="name" id="patch"><span class="type-signature"></span>patch<span class="signature">(baseUrl, request)</span><span class="type-signature"></span></h4>
1088
1089
1090
1091
1092
1093
1094<dl class="details">
1095
1096
1097 <dt class="tag-source">Source:</dt>
1098 <dd class="tag-source"><ul class="dummy"><li>
1099 <a href="client.js.html">client.js</a>, <a href="client.js.html#line130">line 130</a>
1100 </li></ul></dd>
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132</dl>
1133
1134
1135
1136
1137
1138<div class="description">
1139 <p>Make a HTTP PATCH request</p>
1140</div>
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150 <h5>Example</h5>
1151
1152 <pre class="prettyprint"><code>const httpTransport = require('@bbc/http-transport');
1153
1154const response = await httpTransport.createClient()
1155 .put(baseUrl, requestBody)
1156 .asResponse();</code></pre>
1157
1158
1159
1160
1161 <h5>Parameters:</h5>
1162
1163
1164<table class="params">
1165 <thead>
1166 <tr>
1167
1168 <th>Name</th>
1169
1170
1171 <th>Type</th>
1172
1173
1174
1175
1176
1177 <th class="last">Description</th>
1178 </tr>
1179 </thead>
1180
1181 <tbody>
1182
1183
1184 <tr>
1185
1186 <td class="name"><code>baseUrl</code></td>
1187
1188
1189 <td class="type">
1190
1191
1192<span class="param-type">string</span>
1193
1194
1195
1196 </td>
1197
1198
1199
1200
1201
1202 <td class="description last"></td>
1203 </tr>
1204
1205
1206
1207 <tr>
1208
1209 <td class="name"><code>request</code></td>
1210
1211
1212 <td class="type">
1213
1214
1215<span class="param-type">object</span>
1216
1217
1218
1219 </td>
1220
1221
1222
1223
1224
1225 <td class="description last"><p>body</p></td>
1226 </tr>
1227
1228
1229 </tbody>
1230</table>
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245<h5>Returns:</h5>
1246
1247
1248<div class="param-desc">
1249 <p>a HttpTransport instance</p>
1250</div>
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262 <h4 class="name" id="post"><span class="type-signature"></span>post<span class="signature">(baseUrl, request)</span><span class="type-signature"></span></h4>
1263
1264
1265
1266
1267
1268
1269<dl class="details">
1270
1271
1272 <dt class="tag-source">Source:</dt>
1273 <dd class="tag-source"><ul class="dummy"><li>
1274 <a href="client.js.html">client.js</a>, <a href="client.js.html#line71">line 71</a>
1275 </li></ul></dd>
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307</dl>
1308
1309
1310
1311
1312
1313<div class="description">
1314 <p>Make a HTTP POST request</p>
1315</div>
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325 <h5>Example</h5>
1326
1327 <pre class="prettyprint"><code>const httpTransport = require('@bbc/http-transport');
1328
1329const response = await httpTransport.createClient()
1330 .post(baseUrl, requestBody)
1331 .asResponse();</code></pre>
1332
1333
1334
1335
1336 <h5>Parameters:</h5>
1337
1338
1339<table class="params">
1340 <thead>
1341 <tr>
1342
1343 <th>Name</th>
1344
1345
1346 <th>Type</th>
1347
1348
1349
1350
1351
1352 <th class="last">Description</th>
1353 </tr>
1354 </thead>
1355
1356 <tbody>
1357
1358
1359 <tr>
1360
1361 <td class="name"><code>baseUrl</code></td>
1362
1363
1364 <td class="type">
1365
1366
1367<span class="param-type">string</span>
1368
1369
1370
1371 </td>
1372
1373
1374
1375
1376
1377 <td class="description last"></td>
1378 </tr>
1379
1380
1381
1382 <tr>
1383
1384 <td class="name"><code>request</code></td>
1385
1386
1387 <td class="type">
1388
1389
1390<span class="param-type">object</span>
1391
1392
1393
1394 </td>
1395
1396
1397
1398
1399
1400 <td class="description last"><p>body</p></td>
1401 </tr>
1402
1403
1404 </tbody>
1405</table>
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420<h5>Returns:</h5>
1421
1422
1423<div class="param-desc">
1424 <p>a HttpTransport instance</p>
1425</div>
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437 <h4 class="name" id="put"><span class="type-signature"></span>put<span class="signature">(baseUrl, request)</span><span class="type-signature"></span></h4>
1438
1439
1440
1441
1442
1443
1444<dl class="details">
1445
1446
1447 <dt class="tag-source">Source:</dt>
1448 <dd class="tag-source"><ul class="dummy"><li>
1449 <a href="client.js.html">client.js</a>, <a href="client.js.html#line92">line 92</a>
1450 </li></ul></dd>
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482</dl>
1483
1484
1485
1486
1487
1488<div class="description">
1489 <p>Make a HTTP PUT request</p>
1490</div>
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500 <h5>Example</h5>
1501
1502 <pre class="prettyprint"><code>const httpTransport = require('@bbc/http-transport');
1503
1504const response = await httpTransport.createClient()
1505 .put(baseUrl, requestBody)
1506 .asResponse();</code></pre>
1507
1508
1509
1510
1511 <h5>Parameters:</h5>
1512
1513
1514<table class="params">
1515 <thead>
1516 <tr>
1517
1518 <th>Name</th>
1519
1520
1521 <th>Type</th>
1522
1523
1524
1525
1526
1527 <th class="last">Description</th>
1528 </tr>
1529 </thead>
1530
1531 <tbody>
1532
1533
1534 <tr>
1535
1536 <td class="name"><code>baseUrl</code></td>
1537
1538
1539 <td class="type">
1540
1541
1542<span class="param-type">string</span>
1543
1544
1545
1546 </td>
1547
1548
1549
1550
1551
1552 <td class="description last"></td>
1553 </tr>
1554
1555
1556
1557 <tr>
1558
1559 <td class="name"><code>request</code></td>
1560
1561
1562 <td class="type">
1563
1564
1565<span class="param-type">object</span>
1566
1567
1568
1569 </td>
1570
1571
1572
1573
1574
1575 <td class="description last"><p>body</p></td>
1576 </tr>
1577
1578
1579 </tbody>
1580</table>
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595<h5>Returns:</h5>
1596
1597
1598<div class="param-desc">
1599 <p>a HttpTransport instance</p>
1600</div>
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612 <h4 class="name" id="query"><span class="type-signature"></span>query<span class="signature">(name, value)</span><span class="type-signature"></span></h4>
1613
1614
1615
1616
1617
1618
1619<dl class="details">
1620
1621
1622 <dt class="tag-source">Source:</dt>
1623 <dd class="tag-source"><ul class="dummy"><li>
1624 <a href="client.js.html">client.js</a>, <a href="client.js.html#line193">line 193</a>
1625 </li></ul></dd>
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657</dl>
1658
1659
1660
1661
1662
1663<div class="description">
1664 <p>Sets the query strings</p>
1665</div>
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675 <h5>Example</h5>
1676
1677 <pre class="prettyprint"><code>const httpTransport = require('@bbc/http-transport');
1678
1679const response = await httpTransport.createClient()
1680 .query({
1681 'perPage' : 1
1682 })
1683 .asResponse();</code></pre>
1684
1685
1686
1687
1688 <h5>Parameters:</h5>
1689
1690
1691<table class="params">
1692 <thead>
1693 <tr>
1694
1695 <th>Name</th>
1696
1697
1698 <th>Type</th>
1699
1700
1701
1702
1703
1704 <th class="last">Description</th>
1705 </tr>
1706 </thead>
1707
1708 <tbody>
1709
1710
1711 <tr>
1712
1713 <td class="name"><code>name</code></td>
1714
1715
1716 <td class="type">
1717
1718
1719<span class="param-type">string</span>
1720|
1721
1722<span class="param-type">object</span>
1723
1724
1725
1726 </td>
1727
1728
1729
1730
1731
1732 <td class="description last"><p>query name or query object</p></td>
1733 </tr>
1734
1735
1736
1737 <tr>
1738
1739 <td class="name"><code>value</code></td>
1740
1741
1742 <td class="type">
1743
1744
1745<span class="param-type">string</span>
1746|
1747
1748<span class="param-type">object</span>
1749
1750
1751
1752 </td>
1753
1754
1755
1756
1757
1758 <td class="description last"><p>query value</p></td>
1759 </tr>
1760
1761
1762 </tbody>
1763</table>
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778<h5>Returns:</h5>
1779
1780
1781<div class="param-desc">
1782 <p>a HttpTransport instance</p>
1783</div>
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795 <h4 class="name" id="retry"><span class="type-signature"></span>retry<span class="signature">(retries)</span><span class="type-signature"></span></h4>
1796
1797
1798
1799
1800
1801
1802<dl class="details">
1803
1804
1805 <dt class="tag-source">Source:</dt>
1806 <dd class="tag-source"><ul class="dummy"><li>
1807 <a href="client.js.html">client.js</a>, <a href="client.js.html#line230">line 230</a>
1808 </li></ul></dd>
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840</dl>
1841
1842
1843
1844
1845
1846<div class="description">
1847 <p>Set the number of retries on failure for the request</p>
1848</div>
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858 <h5>Example</h5>
1859
1860 <pre class="prettyprint"><code>const httpTransport = require('@bbc/http-transport');
1861
1862const response = await httpTransport.createClient()
1863 .retry(5) // for this request only
1864 .asResponse();</code></pre>
1865
1866
1867
1868
1869 <h5>Parameters:</h5>
1870
1871
1872<table class="params">
1873 <thead>
1874 <tr>
1875
1876 <th>Name</th>
1877
1878
1879 <th>Type</th>
1880
1881
1882
1883
1884
1885 <th class="last">Description</th>
1886 </tr>
1887 </thead>
1888
1889 <tbody>
1890
1891
1892 <tr>
1893
1894 <td class="name"><code>retries</code></td>
1895
1896
1897 <td class="type">
1898
1899
1900<span class="param-type">integer</span>
1901
1902
1903
1904 </td>
1905
1906
1907
1908
1909
1910 <td class="description last"><p>number of times to retry a failed request</p></td>
1911 </tr>
1912
1913
1914 </tbody>
1915</table>
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930<h5>Returns:</h5>
1931
1932
1933<div class="param-desc">
1934 <p>a HttpTransport instance</p>
1935</div>
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947 <h4 class="name" id="retryDelay"><span class="type-signature"></span>retryDelay<span class="signature">(delay)</span><span class="type-signature"></span></h4>
1948
1949
1950
1951
1952
1953
1954<dl class="details">
1955
1956
1957 <dt class="tag-source">Source:</dt>
1958 <dd class="tag-source"><ul class="dummy"><li>
1959 <a href="client.js.html">client.js</a>, <a href="client.js.html#line248">line 248</a>
1960 </li></ul></dd>
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992</dl>
1993
1994
1995
1996
1997
1998<div class="description">
1999 <p>Set the delay between retries in ms</p>
2000</div>
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010 <h5>Example</h5>
2011
2012 <pre class="prettyprint"><code>const httpTransport = require('@bbc/http-transport');
2013
2014const response = await httpTransport.createClient()
2015 .retry(2)
2016 .retryDelay(200)
2017 .asResponse();</code></pre>
2018
2019
2020
2021
2022 <h5>Parameters:</h5>
2023
2024
2025<table class="params">
2026 <thead>
2027 <tr>
2028
2029 <th>Name</th>
2030
2031
2032 <th>Type</th>
2033
2034
2035
2036
2037
2038 <th class="last">Description</th>
2039 </tr>
2040 </thead>
2041
2042 <tbody>
2043
2044
2045 <tr>
2046
2047 <td class="name"><code>delay</code></td>
2048
2049
2050 <td class="type">
2051
2052
2053<span class="param-type">integer</span>
2054
2055
2056
2057 </td>
2058
2059
2060
2061
2062
2063 <td class="description last"><p>number of ms to wait between retries (default: 100)</p></td>
2064 </tr>
2065
2066
2067 </tbody>
2068</table>
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083<h5>Returns:</h5>
2084
2085
2086<div class="param-desc">
2087 <p>a HttpTransport instance</p>
2088</div>
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100 <h4 class="name" id="timeout"><span class="type-signature"></span>timeout<span class="signature">(time)</span><span class="type-signature"></span></h4>
2101
2102
2103
2104
2105
2106
2107<dl class="details">
2108
2109
2110 <dt class="tag-source">Source:</dt>
2111 <dd class="tag-source"><ul class="dummy"><li>
2112 <a href="client.js.html">client.js</a>, <a href="client.js.html#line213">line 213</a>
2113 </li></ul></dd>
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145</dl>
2146
2147
2148
2149
2150
2151<div class="description">
2152 <p>Sets a request timeout</p>
2153</div>
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163 <h5>Example</h5>
2164
2165 <pre class="prettyprint"><code>const httpTransport = require('@bbc/http-transport');
2166
2167const response = await httpTransport.createClient()
2168 .timeout(1)
2169 .asResponse();</code></pre>
2170
2171
2172
2173
2174 <h5>Parameters:</h5>
2175
2176
2177<table class="params">
2178 <thead>
2179 <tr>
2180
2181 <th>Name</th>
2182
2183
2184 <th>Type</th>
2185
2186
2187
2188
2189
2190 <th class="last">Description</th>
2191 </tr>
2192 </thead>
2193
2194 <tbody>
2195
2196
2197 <tr>
2198
2199 <td class="name"><code>time</code></td>
2200
2201
2202 <td class="type">
2203
2204
2205<span class="param-type">integer</span>
2206
2207
2208
2209 </td>
2210
2211
2212
2213
2214
2215 <td class="description last"><p>timeout in seconds</p></td>
2216 </tr>
2217
2218
2219 </tbody>
2220</table>
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235<h5>Returns:</h5>
2236
2237
2238<div class="param-desc">
2239 <p>a HttpTransport instance</p>
2240</div>
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252 <h4 class="name" id="use"><span class="type-signature"></span>use<span class="signature">(fn)</span><span class="type-signature"></span></h4>
2253
2254
2255
2256
2257
2258
2259<dl class="details">
2260
2261
2262 <dt class="tag-source">Source:</dt>
2263 <dd class="tag-source"><ul class="dummy"><li>
2264 <a href="client.js.html">client.js</a>, <a href="client.js.html#line35">line 35</a>
2265 </li></ul></dd>
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297</dl>
2298
2299
2300
2301
2302
2303<div class="description">
2304 <p>Registers a per request plugin</p>
2305</div>
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315 <h5>Example</h5>
2316
2317 <pre class="prettyprint"><code>const toError = require('@bbc/http-transport-to-error');
2318const httpTransport = require('@bbc/http-transport');
2319
2320httpTransport.createClient()
2321 .use(toError(404));</code></pre>
2322
2323
2324
2325
2326 <h5>Parameters:</h5>
2327
2328
2329<table class="params">
2330 <thead>
2331 <tr>
2332
2333 <th>Name</th>
2334
2335
2336 <th>Type</th>
2337
2338
2339
2340
2341
2342 <th class="last">Description</th>
2343 </tr>
2344 </thead>
2345
2346 <tbody>
2347
2348
2349 <tr>
2350
2351 <td class="name"><code>fn</code></td>
2352
2353
2354 <td class="type">
2355
2356
2357<span class="param-type">function</span>
2358
2359
2360
2361 </td>
2362
2363
2364
2365
2366
2367 <td class="description last"><p>per request plugin</p></td>
2368 </tr>
2369
2370
2371 </tbody>
2372</table>
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387<h5>Returns:</h5>
2388
2389
2390<div class="param-desc">
2391 <p>a HttpTransport instance</p>
2392</div>
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405</article>
2406
2407</section>
2408
2409
2410
2411
2412</div>
2413
2414<br class="clear">
2415
2416<footer>
2417 Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.11</a> on Fri Sep 22 2023 15:20:00 GMT+0100 (British Summer Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
2418</footer>
2419
2420<script>prettyPrint();</script>
2421<script src="scripts/linenumber.js"></script>
2422</body>
2423</html>
\No newline at end of file