【问题标题】:What's the correct way to send parameters from AngularJS to an Options HTTP API?将参数从 AngularJS 发送到 Options HTTP API 的正确方法是什么?
【发布时间】:2015-08-18 08:36:00
【问题描述】:

在带有参数的选项 HTTP API 之间对话的正确代码是什么?

        return $http( {
            method: 'OPTIONS',
            url: apiUrl + '/Options/' + clientID
        } ).error( function ( a, b, c, d, e ) {
            console.log( 'a, b, c, d, e', a, b, c, d, e );
        } );

【问题讨论】:

  • 请分享你得到的结果
  • API url 完全依赖于 api。我们不可能提前知道正确的端点需要是什么,除非您告诉我们您要访问的服务器,例如 github、google maps 等。其中许多 API 还没有实现 OPTIONS。另外,我认为 Angular 的 $http 没有 .options 速记,因此您的第二次尝试看起来更准确。
  • @azium ,感谢您的回复,我只需要知道它是否可能 - API 是一个内部 API,我知道有参数并实现了选项,但由于某种原因我的代码是'没有到达 API 代码。谢谢 - 我会继续努力

标签: angular-routing http-options-method


【解决方案1】:

试试这个方法

        return $http( {
            method: 'OPTIONS',
            url: apiUrl + '/Options?clientID=' + clientID
        } ).error( function ( a, b, c, d, e ) {
            console.log( 'err' );
        } );

【讨论】:

    猜你喜欢
    • 2018-01-12
    • 1970-01-01
    • 2021-05-25
    • 2020-08-12
    • 2010-10-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-03
    相关资源
    最近更新 更多