Skip to main content
Version: v5.2

IafFetch

IafFetch is a higher-level API that simplifies HTTP requests. Use the API to complete the following actions:Concatenate arguments with slashes to construct a URLMake HTTP GET, POST, PUT, and DELETE request with a URL you pass

constructUrl

Takes arguments you pass and concatenates them with slashes to construct a URL.

ParameterRequiredTypeDescription
segmentsYesUNKNOWN: RestTypeOne or more URL segments to join with slashes. The first segment is typically the base URL.
Returns

string - The constructed URL

Examples
//The following outputs 'http://localhost:8080/passportsvc/api/v1/workspaces/7b56c039-6044-43ae-9b3d-be9cf31a9d18'
IafFetch.constructUrl('http://localhost:8080/passportsvc/api/v1/', 'workspaces', '7b56c039-6044-43ae-9b3d-be9cf31a9d18')

doDelete

Makes a HTTP DELETE request with a URL you pass.

ParameterRequiredTypeDescription
urlYesStringPass the complete resource URL.
bodyNoStringOptional request body. Most DELETE requests do not require a body as the resource is identified by the URL. Pass if no body is needed.
ctxNoCtxFor authentication, you can pass the context storage if it contains the required auth token.
optionsNoObjectTo pass headers, pass an object called "options" and add a "headers" property with your headers as the value.
Returns

Promise<> -

Examples
let url = "http://localhost:8080/passportsvc/api/v1/workspaces/";
let body = "7b56c039-6044-43ae-9b3d-be9cf31a9d18";

const response = await IafFetch.doDelete(url, body, ctx);

doGet

Makes a HTTP GET request with a URL you pass.

ParameterRequiredTypeDescription
urlYesStringPass the complete resource URL.
ctxNoCtxFor authentication, you can pass the context storage if it contains the required auth token.
optionsNoObjectTo pass headers, pass an object called "options" and add a "headers" property with your headers as the value.
parsingFunctionYesundefined
Returns

Promise<> -

Examples
let url = "http://localhost:8080/passportsvc/api/v1/workspaces/7b56c039-6044-43ae-9b3d-be9cf31a9d18";
let options = { headers: {Accept-Language: en} };

const response = await IafFetch.doGet(url, ctx, options);

doPatch

Makes a HTTP PATCH request with a URL you pass.

ParameterRequiredTypeDescription
urlYesStringPass the complete resource URL.
bodyYesStringPass the request body you want to send.
ctxNoCtxFor authentication, you can pass the context storage if it contains the required auth token.
optionsNoObjectTo pass headers, pass an object called "options" and add a "headers" property with your headers as the value.
Returns

Promise<> -

Examples
let url = "http://localhost:8080/passportsvc/api/v1/applications/dab338b7-be5f-4538-bcf0-cf38a2a760c7/configs";
let body = {
"usergroups.limit": 5
};

const response = await IafFetch.doPatch(url, body, ctx);

doPost

Makes a HTTP POST request with a URL you pass.

ParameterRequiredTypeDescription
urlYesStringPass the complete resource URL.
bodyYesStringPass the request body you want to send.
ctxNoCtxFor authentication, you can pass the context storage if it contains the required auth token.
optionsNoObjectTo pass headers, pass an object called "options" and add a "headers" property with your headers as the value.
Returns

Promise<> -

Examples
let url = "http://localhost:8080/passportsvc/api/v1/workspaces/7b56c039-6044-43ae-9b3d-be9cf31a9d18";
let body = "status=on";
let options = { headers: { Accept-Language: en } };

const response = await IafFetch.doPost(url, body, ctx, options);

doPut

Makes a HTTP PUT request with a URL you pass.

ParameterRequiredTypeDescription
urlYesStringPass the complete resource URL.
bodyYesStringPass the request body you want to send.
ctxNoCtxFor authentication, you can pass the context storage if it contains the required auth token.
optionsNoObjectTo pass headers, pass an object called "options" and add a "headers" property with your headers as the value.
Returns

Promise<> -

Examples
let url = "http://localhost:8080/passportsvc/api/v1/workspaces/";
let body = "7b56c039-6044-43ae-9b3d-be9cf31a9d18";

const response = await IafFetch.doPut(url, body, ctx);