Skip to main content

addData()

Last updated 30/10/2023

The code is creating an instance of the HTTPClient using the function httpClient() on the five object. The example will send a GET request to the fakestoreapi carts endpoint with userID equals 1 using the addData() function.

Adding a GET parameter using the addData() function
    // create an instance of the HTTPClient using the function httpClient on the five object
const webClient = five.httpClient();

// add data to be sent with the GET request as a url parameter
webClient.addData("userId", "1");

// perform a GET request to the server, the resulting url will be : https://fakestoreapi.com/carts?userId=1
const response = webClient.get(webClient.RAW, 'https://fakestoreapi.com/carts');