• POST HTTP request

    Parameters

    Returns PostOperation

    Operation for POST request

    Throws

    • RestApiError

    Example

    Send a POST request

    import { post, isCancelError } from '@aws-amplify/api';

    const { body } = await post({
    apiName,
    path,
    options: {
    headers, // Optional, A map of custom header key/values
    body, // Optional, JSON object or FormData
    queryParams, // Optional, A map of query strings
    }
    }).response;
    const data = await body.json();

    Example

    Cancel a POST request

    import { post, isCancelError } from '@aws-amplify/api';

    const { response, cancel } = post({apiName, path, options});
    cancel(message);
    try {
    await response;
    } catch (e) {
    if (isCancelError(e)) {
    // handle request cancellation
    }
    //...
    }