Types: added definitions for fetch method.
diff --git a/test/ts/test.ts b/test/ts/test.ts
index 65cf52f..ef24d70 100644
--- a/test/ts/test.ts
+++ b/test/ts/test.ts
@@ -82,6 +82,17 @@
 
     // r.responseBuffer
     r.responseBuffer?.equals(Buffer.from([1]));
+
+    ngx.fetch('http://nginx.org/', {method:'POST', headers:{Foo:'bar'}})
+    .then(reply => {
+        if (reply.headers.get('foo')) {
+            throw 'oops'
+        };
+
+        return reply.text()
+    })
+    .then(body => r.return(200, body))
+    .catch(e => r.return(501, e.message))
 }
 
 function fs_module() {
diff --git a/ts/ngx_core.d.ts b/ts/ngx_core.d.ts
index 258a27f..4a02f14 100644
--- a/ts/ngx_core.d.ts
+++ b/ts/ngx_core.d.ts
@@ -1,3 +1,102 @@
+interface NgxResponseHeaders {
+    /**
+     * Returns a string containing the values of all headers
+     * with the specified name separated by a comma and a space.
+     * @param name A name of the header.
+     */
+    get(name:NjsStringLike): NjsByteString;
+    /**
+     * Returns an array containing the values of all headers
+     * with the specified name.
+     * @param name A name of the header.
+     */
+    getAll(name:NjsStringLike): NjsByteString;
+    /**
+     * Returns a boolean value indicating whether a header with
+     * the specified name exists.
+     * @param name A name of the header.
+     */
+    has(name:NjsStringLike): NjsByteString;
+}
+
+interface NgxResponse {
+    /**
+     * Takes a Response stream and reads it to completion.
+     * Returns a Promise that resolves with an ArrayBuffer.
+     */
+    arrayBuffer(): Promise<ArrayBuffer>;
+    /**
+     * A boolean value, true if the body has been used.
+     */
+    readonly bodyUsed: boolean;
+    /**
+     * Takes a Response stream and reads it to completion.
+     * Returns a Promise that resolves with the result of
+     * parsing the body text as JSON.
+     */
+    json(): Promise<Object>;
+    /**
+     * The NgxResponseHeaders object associated with the response.
+     */
+    headers: NgxResponseHeaders;
+    /**
+     * A boolean value, true if the response was successful
+     * (status in the range 200-299).
+     */
+    readonly ok: boolean;
+    /**
+     * A boolean value, true if the response is the result
+     * of a redirect.
+     */
+    readonly redirected: boolean;
+    /**
+     * The status code of the response.
+     */
+    readonly status: number;
+    /**
+     * The status message corresponding to the status code.
+     */
+    readonly statusText: NjsByteString;
+    /**
+     * Takes a Response stream and reads it to completion.
+     * Returns a Promise that resolves with a string.
+     */
+    text(): Promise<NjsByteString>;
+    /**
+     * The type of the response.
+     */
+    readonly type: NjsByteString;
+    /**
+     * Response url.
+     */
+    readonly url: NjsByteString;
+}
+
+interface NgxFetchOptions {
+    /**
+     * Request body, by default is empty.
+     */
+    body?: NjsStringLike,
+    /**
+     * The buffer size for reading the response, by default is 4096.
+     * Nginx specific.
+     */
+    buffer_size?: Number,
+    /**
+     * Request headers object.
+     */
+    headers?: Object,
+    /**
+     * The maximum size of the response body in bytes, by default is 32768.
+     * Nginx specific.
+     */
+    max_response_body_size?: Number,
+    /**
+     * Request method, by default the GET method is used.
+     */
+    method?: NjsStringLike;
+}
+
 interface NgxObject {
     readonly INFO: number;
     readonly WARN: number;
@@ -9,6 +108,15 @@
      * @param message Message to log.
      */
     log(level: number, message: NjsStringOrBuffer): void;
+    /**
+     * Makes a request to fetch an URL.
+     * Returns a Promise that resolves with the NgxResponse object.
+     * Only the http:// scheme is supported, redirects are not handled.
+     * @param url URL of a resource to fetch.
+     * @param options An object containing additional settings.
+     * @since 0.5.1
+     */
+    fetch(url: NjsStringOrBuffer, options?: NgxFetchOptions): Promise<NgxResponse>;
 }
 
 declare const ngx: NgxObject;