You're viewing **Apigee Edge** documentation.  
[Go to the
**Apigee X** documentation](http://cloud.google.com/apigee/docs/api-platform/develop/resource-files). info

This topic discusses some of the API proxy development patterns demonstrated in the Apigee
Edge cookbook samples. As we add more cookbook samples, we plan to add more patterns to this
topic.

## The JavaScript HTTP client pattern

The JavaScript HTTP client pattern is one of several patterns that you can use to create
**server-side mashups** with Apigee Edge. Apigee's JavaScript Object Model allows
you to wire JavaScript code directly into an API proxy flow. The object
model's **httpClient** object allows you to make calls to backend services and
retrieve results using JavaScript.

> [!IMPORTANT]
> **Tip:** The JavaScript HTTP client pattern is only one of several ways to create mashups with Apigee API proxies. If you are prefer editing XML files, policy composition may be the best technique for you. If you prefer writing server-side JavaScript code, you can develop a JavaScript client application or a Node.js application to achieve the same results.

## The policy composition pattern

Policy composition is an Apigee API proxy pattern that lets you combine results from multiple
backend targets into a single response using policies. In effect, policy composition lets you
create mashups using policies.

> [!IMPORTANT]
> **Tip:** Policy composition is only one of several ways to create mashups with Apigee API proxies. If you prefer editing XML files to writing code, then policy composition may be the best technique for you. If you prefer writing server-side JavaScript code, you can develop a JavaScript client application or a Node.js application to achieve the same results.

At the heart of the policy composition pattern is the [ServiceCallout](https://docs.apigee.com/api-platform/reference/policies/service-callout-policy) policy.
The ServiceCallout policy acts as an HTTP client to the backend API or service. To be completely
functional, however, a ServiceCallout relies on other policies to enable meaningful interaction
with a remote API or service. Other policies are used to generate the request message that is
sent by the ServiceCallout and to parse the content in the response message from the remote API
or service.
The [policy
composition cookbook example](https://docs.apigee.com/api-platform/samples/cookbook/using-policy-composition) uses three policies: [AssignMessage](https://docs.apigee.com/api-platform/reference/policies/assign-message-policy), [ServiceCallout](https://docs.apigee.com/api-platform/reference/policies/service-callout-policy),
and [ExtractVariables](https://docs.apigee.com/api-platform/reference/policies/extract-variables-policy). These
policies encapsulate the **request** message(s) you wish to send to the
backend, the **client** that routes the message to the backend, and
a **message parser** that parses the response from each API and assigns
variables for the response data. After all the calls have been made, the collected variables
are combined and returned in a single JSON object.

Here's a quick summary of these three policies:

- **AssignMessage**: Creates a request message, populates HTTP headers and query parameters, sets the HTTP verb.
- **ServiceCallout**: References a message created by the AssignMessage policy, defines a target URL for the external call, and defines a name for the response object that the target service returns.
- **ExtractVariables**: Typically defines a JSONPath or XPath expression that parses the message generated by the preceding ServiceCallout policy. The policy then sets variables containing the values parsed from the ServiceCallout response.

See [Using policy
composition](https://docs.apigee.com/api-platform/samples/cookbook/using-policy-composition) for a complete example demonstrating the policy composition pattern.