@@ -120,6 +120,8 @@ Reference List
120
120
- read or modify cookies
121
121
* - :ref: `effect <frontend/services/effect >`
122
122
- display graphical effects
123
+ * - :ref: `http <frontend/services/http >`
124
+ - perform low level http calls
123
125
* - :ref: `notification <frontend/services/notification >`
124
126
- display notifications
125
127
* - :ref: `router <frontend/services/router >`
@@ -343,6 +345,52 @@ Here, it is called in webclient.js to make it visible everywhere for the example
343
345
:width: 600
344
346
:align: center
345
347
348
+ .. _frontend/services/http :
349
+
350
+ Http Service
351
+ ------------
352
+
353
+ Overview
354
+ ~~~~~~~~
355
+
356
+ * Technical name: `http `
357
+ * Dependencies: None
358
+
359
+ While most interactions between the client and the server in odoo are `RPCs ` (`XMLHTTPRequest `), lower level
360
+ control on requests may sometimes be required.
361
+
362
+ This service provides a way to send `get ` and `post ` `http requests <https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods >`_.
363
+
364
+ API
365
+ ~~~
366
+
367
+ .. js :function :: async get (route[,readMethod = " json" ])
368
+
369
+ :param string route: the url to send the request to
370
+ :param string readMethod: the response content type. Can be "text", "json", "formData", "blob", "arrayBuffer".
371
+ :returns: the result of the request with the format defined by the readMethod argument.
372
+
373
+ Sends a get request.
374
+
375
+ .. js :function :: async post (route [,params = {}, readMethod = " json" ])
376
+
377
+ :param string route: the url to send the request to
378
+ :param object params: key value data to be set in the form data part of the request
379
+ :param string readMethod: the response content type. Can be "text", "json", "formData", "blob", "arrayBuffer".
380
+ :returns: the result of the request with the format defined by the readMethod argument.
381
+
382
+ Sends a post request.
383
+
384
+ Example
385
+ ~~~~~~~
386
+
387
+ .. code-block :: javascript
388
+
389
+ const httpService = useService (" http" );
390
+ const data = await httpService .get (" https://something.com/posts/1" );
391
+ // ...
392
+ await httpService .post (" https://something.com/posts/1" , { title: " new title" , content: " new content" });
393
+
346
394
.. _frontend/services/notification :
347
395
348
396
Notification service
0 commit comments