如何使用ionic 2正确发出http.put请求?

时间:2017-09-14 18:23:11

标签: javascript http ionic-framework ionic2 ionic3

我正在发出请求,但它返回错误,我不知道我做错了

  

" @ angular / http":" 4.1.3"

this.http.put( url, JSON.stringify(body)).map(res => res.json()).subscribe(
    data => {
        console.log('the consultation was completed I think with success:', [data]);
     },
    err => {
        console.log("query error: ", err);
    }
)

错误是以下OPTIONS net :: ERR_EMPTY_RESPONSE,console.log说错误是:

Response {_body: ProgressEvent, status: 0, ok: false, statusText: "", headers: Headers, …}
    headers : Headers {_headers: Map(0), _normalizedNames: Map(0)}
    ok : false
    status : 0
    statusText : ""
    type : 3
    url : null
    _body : ProgressEvent
    bubbles : false
    cancelBubble : false
    cancelable : false
    composed : false
    currentTarget : XMLHttpRequest {__zone_symbol__xhrSync: false, __zone_symbol__eventTasks: Array(0), __zone_symbol__xhrTask: t, readyState: 4, __zone_symbol__xhrListener: ƒ, …}
    defaultPrevented : false
    eventPhase : 0
    isTrusted : true
    lengthComputable : false
    loaded : 0
    path : []
    returnValue : true
    srcElement : XMLHttpRequest {__zone_symbol__xhrSync: false, __zone_symbol__eventTasks: Array(0), __zone_symbol__xhrTask: t, readyState: 4, __zone_symbol__xhrListener: ƒ, …}
    target : XMLHttpRequest {__zone_symbol__xhrSync: false, __zone_symbol__eventTasks: Array(0), __zone_symbol__xhrTask: t, readyState: 4, __zone_symbol__xhrListener: ƒ, …}
    timeStamp : 30986.310000000005
    total : 0
    type : "error"
    __proto__ : ProgressEvent
    __proto__ : Body

如果删除方法.subscribe()不输出任何错误,但检查数据库中我的表的记录是否被修改并且未被修改。

帖子请求工作完美,它与put是我有问题

0 个答案:

没有答案