You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*Endpoint* instances provide access for arbitrary HTTP requests. This allows easy access to Foxx apps and other HTTP APIs not covered by the driver itself.
749
+
*Route* instances provide access for arbitrary HTTP requests. This allows easy access to Foxx apps and other HTTP APIs not covered by the driver itself.
750
750
751
-
### endpoint.endpoint([path, [headers]])
751
+
### route.route([path, [headers]])
752
752
753
-
Creates a new *Endpoint* instance representing the *path* relative to the current endpoint. Optionally *headers* can be an object with headers which will be extended with the current endpoint's headers and the connection's headers.
753
+
Creates a new *Route* instance representing the *path* relative to the current route. Optionally *headers* can be an object with headers which will be extended with the current route's headers and the connection's headers.
754
754
755
755
*Examples*
756
756
757
757
```js
758
758
var db =require('arangojs')();
759
-
varendpoint=db.endpoint('my-foxx-app');
760
-
var users =endpoint.endpoint('users');
761
-
// equivalent to db.endpoint('my-foxx-app/users')
759
+
varroute=db.route('my-foxx-app');
760
+
var users =route.route('users');
761
+
// equivalent to db.route('my-foxx-app/users')
762
762
```
763
763
764
-
### endpoint.get([path,][qs,] callback)
764
+
### route.get([path,][qs,] callback)
765
765
766
766
Performs a GET request to the given URL and passes the server response to the given callback.
767
767
768
768
*Parameter*
769
769
770
-
**path* (optional): the endpoint-relative URL for the request.
770
+
**path* (optional): the route-relative URL for the request.
771
771
**qs* (optional): the query string for the request.
772
772
773
-
If *path* is missing, the request will be made to the base URL of the endpoint.
773
+
If *path* is missing, the request will be made to the base URL of the route.
774
774
775
775
If *qs* is an object, it will be translated to a query string.
776
776
777
777
*Examples*
778
778
779
779
```js
780
780
var db =require('arangojs')();
781
-
varendpoint=db.endpoint('my-foxx-app');
782
-
endpoint.get(function (err, result) {
781
+
varroute=db.route('my-foxx-app');
782
+
route.get(function (err, result) {
783
783
if (err) returnconsole.error(err);
784
784
// result is the response body of calling
785
785
// GET _db/_system/my-foxx-app
786
786
});
787
787
788
788
// -- or --
789
789
790
-
endpoint.get('users', function (err, result) {
790
+
route.get('users', function (err, result) {
791
791
if (err) returnconsole.error(err);
792
792
// result is the response body of calling
793
793
// GET _db/_system/my-foxx-app/users
794
794
});
795
795
796
796
// -- or --
797
797
798
-
endpoint.get('users', {group:'admin'}, function (err, result) {
798
+
route.get('users', {group:'admin'}, function (err, result) {
799
799
if (err) returnconsole.error(err);
800
800
// result is the response body of calling
801
801
// GET _db/_system/my-foxx-app/users?group=admin
802
802
});
803
803
```
804
804
805
-
### endpoint.post([path,][body, [qs,]] callback)
805
+
### route.post([path,][body, [qs,]] callback)
806
806
807
807
Performs a POST request to the given URL and passes the server response to the given callback.
808
808
809
809
*Parameter*
810
810
811
-
**path* (optional): the endpoint-relative URL for the request.
811
+
**path* (optional): the route-relative URL for the request.
812
812
**body* (optional): the request body for the request.
813
813
**qs* (optional): the query string for the request.
814
814
815
-
If *path* is missing, the request will be made to the base URL of the endpoint.
815
+
If *path* is missing, the request will be made to the base URL of the route.
816
816
817
817
If *body* is an object, it will be converted to JSON.
818
818
@@ -822,24 +822,24 @@ If *qs* is an object, it will be translated to a query string.
822
822
823
823
```js
824
824
var db =require('arangojs')();
825
-
varendpoint=db.endpoint('my-foxx-app');
826
-
endpoint.post(function (err, result) {
825
+
varroute=db.route('my-foxx-app');
826
+
route.post(function (err, result) {
827
827
if (err) returnconsole.error(err);
828
828
// result is the response body of calling
829
829
// POST _db/_system/my-foxx-app
830
830
});
831
831
832
832
// -- or --
833
833
834
-
endpoint.post('users', function (err, result) {
834
+
route.post('users', function (err, result) {
835
835
if (err) returnconsole.error(err);
836
836
// result is the response body of calling
837
837
// POST _db/_system/my-foxx-app/users
838
838
});
839
839
840
840
// -- or --
841
841
842
-
endpoint.post('users', {
842
+
route.post('users', {
843
843
username:'admin',
844
844
password:'hunter2'
845
845
}, function (err, result) {
@@ -851,7 +851,7 @@ endpoint.post('users', {
851
851
852
852
// -- or --
853
853
854
-
endpoint.post('users', {
854
+
route.post('users', {
855
855
username:'admin',
856
856
password:'hunter2'
857
857
}, {admin:true}, function (err, result) {
@@ -862,17 +862,17 @@ endpoint.post('users', {
862
862
});
863
863
```
864
864
865
-
### endpoint.put([path,][body, [qs,]] callback)
865
+
### route.put([path,][body, [qs,]] callback)
866
866
867
867
Performs a PUT request to the given URL and passes the server response to the given callback.
868
868
869
869
*Parameter*
870
870
871
-
**path* (optional): the endpoint-relative URL for the request.
871
+
**path* (optional): the route-relative URL for the request.
872
872
**body* (optional): the request body for the request.
873
873
**qs* (optional): the query string for the request.
874
874
875
-
If *path* is missing, the request will be made to the base URL of the endpoint.
875
+
If *path* is missing, the request will be made to the base URL of the route.
876
876
877
877
If *body* is an object, it will be converted to JSON.
878
878
@@ -882,24 +882,24 @@ If *qs* is an object, it will be translated to a query string.
882
882
883
883
```js
884
884
var db =require('arangojs')();
885
-
varendpoint=db.endpoint('my-foxx-app');
886
-
endpoint.put(function (err, result) {
885
+
varroute=db.route('my-foxx-app');
886
+
route.put(function (err, result) {
887
887
if (err) returnconsole.error(err);
888
888
// result is the response body of calling
889
889
// PUT _db/_system/my-foxx-app
890
890
});
891
891
892
892
// -- or --
893
893
894
-
endpoint.put('users/admin', function (err, result) {
0 commit comments