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 scnario, there is no need to make an OPTION call as it is being issued by browsers.

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.
Ramin Ahmadi
I am a full-stack front end developer with over 5 years experience in web design and development. I have worked with a wide variety of environments and languages including Angular, TypeScript, NodeJS, Restful API, Microservices, Atomic design, JQuery, Material design, Progressive Web Apps, DevOps, and many Azure tools. I make it a goal to automate myself out of routine tasks in my daily work. My motto is, ‘write human readable code, lean and clean’.

Comments 0

Your email address will not be published. Required fields are marked *

What is HTTP method OPTIONS?

log in

Captcha!

reset password

Back to
log in
Choose A Format
Trivia quiz
Series of questions with right and wrong answers that intends to check knowledge
Poll
Voting to make decisions or determine opinions
List
The Classic Internet Listicles
Image
Photo or GIF
Gif
GIF format