How can I change the base URL of an AngularJS HTTP call?

后端 未结 4 1967
灰色年华
灰色年华 2021-02-20 10:21

My application calls $HTTP many times like this:

    this.$http({
        method: this.method,
        url: this.url
    })

The this.url is alw

4条回答
  •  遇见更好的自我
    2021-02-20 11:07

    I found a alternative solution instead of tag: written in coffeescript

    $httpProvider.interceptors.push ($q)->
      'request': (config)->
        if config.url.indexOf('/api') is 0
          config.url = BASE_URL+config.url
        config
    

提交回复
热议问题