Skip to main content

headers and parameters

Last updated 24/04/2024

headers and parameters
properties on the
Five
object in functions.

Example

The example below takes new customer details that have been provided as URL encoded parameters, and also checks the Authorization HTTP Header that the username and password are accepted. For the example below, we are expecting Aladdin as the username and open sesame as the password, which are Base64 encoded in the Authorization HTTP Header.

Creating a new customer via a public URL
function SignupCustomer(five: Five, context: any, result: FiveResult): FiveResult {

const authorizationHeader: string = five.headers.Authorication;
const firstName: string = five.parameters.FirstName;
const lastName: string = five.parameters.LastName;
const emailAddress: string = five.parameters.Email;

if (authorizationHeader !== 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==') {
return five.createError(result, "Invalid user");
}

const insertResult = five.executeQuery('CreateCustomerQ', 0, firstName, lastName, emailAddress);
if (insertResult.isOk() === false {
return five.createError(result, "Failed to create customer");
}

return five.success(result);
}