http.get being called twice

前端 未结 1 2007
悲哀的现实
悲哀的现实 2021-01-17 06:20

I have this http.get request but it is being triggered twice. It is within my constructor.

import { Component } from \'@angular/core\';
import { NavControll         


        
1条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-17 07:05

    You mentioned the OPTIONS request. Are you running the angular 2 site from a different server than your API?

    If so, then you'll have to deal with CORS - i.e. the browser will send a first OPTIONS request and check the headers of the response to see if CORS is permitted.

    That would explain why you see two requests on your back end API

    0 讨论(0)
提交回复
热议问题