Ramin Ahmadi | Personal website of Ramin Ahmadi

What is HTTP method OPTIONS?

The HTTP OPTIONS method is a type of HTTP call that explains what are the options for a target resource such as API endpoint.

a client can use target resource’s URL to use OPTIONS method or use * to target the entire server.

public GetOtaAdaptor(): Promise<Model.OtaAdapter> {
        return new Promise<Model.myModel>((resolve, reject) => {
            this.http.options<Model.myModel>(this.root + `end/point/URL`  ).subscribe(
                result => {
                    resolve(result);
                },
                error => {
                    reject(error);
                });
            });
        }

when using Cross-Origin Resource Sharing (CORS), a preflight request with OPTIONS is being automatically sent, so the target resource would respond with acceptable parameters. In normal web development scenario, there is no need to make an OPTION call as it is being issued by browsers.

HTTP option method call

In above example, The Access-Control-Request-Method header informs the server as part of a preflight request that a request is being sent, it will be sent with a POST request method.

Leave a Comment.