Skip to main content
Version: v4.6

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.

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.
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.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);