ArangoDB v3.4 reached End of Life (EOL) and is no longer supported.

This documentation is outdated. Please see the most recent version here: Latest Docs

Making requests

ArangoDB is primarily a database, so Foxx doesn’t offer the same level of network access as more general-purpose JavaScript environments like Node.js. However ArangoDB does provide the @arangodb/request module for making HTTP (or HTTPS) requests:

"use strict";
const request = require("@arangodb/request");
const response = request.get(
  "https://pokeapi.co/api/v2/pokemon/25/"
);
if (response.status < 400) {
  const pikachu = response.json;
  console.log(pikachu);
}

Because Foxx services are always synchronous and network requests can be considerably slower than any other database operation, you should avoid making requests in your service if possible or use queues instead.

By using an absolute path instead of a full URL, you can also use the request module to talk to ArangoDB itself, for example in integration tests:

const response = request.get("/_db/_system/myfoxx/something");

Note: Although making local requests doesn’t create the network overhead as making requests to other servers, special care needs to be taken when talking to services on the same server. If you want to connect services in the same database you should use dependencies instead.