最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

复制与卷曲在取js函数

IT培训 admin 3浏览 0评论

复制与卷曲在取js函数

我有一个返回一个HTTP请求缓存的应用程序。当我在终端上运行卷曲我得到一个正确的回应:

卷曲:

curl -s -X GET \  "url" \  -H "authorization: Bearer token" \  -H "content-type: application/json"

响应:

Pendiente now has [{"Key":"73ef53d2848708ae3288db3afb69ee85a663eba2ab147e83494f65585d171a2d","Record":{"cantidad":"100","docType":"fabricacion","estado":"Pendiente","id":"73ef53d2848708ae3288db3afb69ee85a663eba2ab147e83494f65585d171a2d","mercado":"dercadona","owner":"jose","producto":"manzanas","usuario":"jose"}},{"Key":"9b2d52becf9620971c7fd31c54b817533157cb2c7186dd3835f4c502742418b5","Record":{"cantidad":"200","docType":"fabricacion","estado":"Pendiente","id":"9b2d52becf9620971c7fd31c54b817533157cb2c7186dd3835f4c502742418b5","mercado":"mercadona","owner":"jose","producto":"peras","usuario":"jose"}}] after the move

我试图从响应得到JSON部分用JS读取(取内的另一个获取云)。我已经试过各种方法,但我不能设法得到它正确

return fetch(url_get_tx,{
        method: 'get',
        headers: {
            'Content-type': 'multipart/form-data',
            'authorization': 'Bearer '+data.token
        }
    }
.then(function(data) {
    var reader = data.body.getReader();
    return reader.read()
    console.log("here");
    console.log(typeof(reader));
    console.log(reader);

})

非常感谢

回答如下:
return fetch(url_get_tx,{
    method: 'get',
    headers: {
        'Content-type': 'application/json'
        'authorization': 'Bearer '+data.token
    }
})
.then(function(data) {
return data.json()

}).then(result => console.log(result))

复制与卷曲在取js函数

我有一个返回一个HTTP请求缓存的应用程序。当我在终端上运行卷曲我得到一个正确的回应:

卷曲:

curl -s -X GET \  "url" \  -H "authorization: Bearer token" \  -H "content-type: application/json"

响应:

Pendiente now has [{"Key":"73ef53d2848708ae3288db3afb69ee85a663eba2ab147e83494f65585d171a2d","Record":{"cantidad":"100","docType":"fabricacion","estado":"Pendiente","id":"73ef53d2848708ae3288db3afb69ee85a663eba2ab147e83494f65585d171a2d","mercado":"dercadona","owner":"jose","producto":"manzanas","usuario":"jose"}},{"Key":"9b2d52becf9620971c7fd31c54b817533157cb2c7186dd3835f4c502742418b5","Record":{"cantidad":"200","docType":"fabricacion","estado":"Pendiente","id":"9b2d52becf9620971c7fd31c54b817533157cb2c7186dd3835f4c502742418b5","mercado":"mercadona","owner":"jose","producto":"peras","usuario":"jose"}}] after the move

我试图从响应得到JSON部分用JS读取(取内的另一个获取云)。我已经试过各种方法,但我不能设法得到它正确

return fetch(url_get_tx,{
        method: 'get',
        headers: {
            'Content-type': 'multipart/form-data',
            'authorization': 'Bearer '+data.token
        }
    }
.then(function(data) {
    var reader = data.body.getReader();
    return reader.read()
    console.log("here");
    console.log(typeof(reader));
    console.log(reader);

})

非常感谢

回答如下:
return fetch(url_get_tx,{
    method: 'get',
    headers: {
        'Content-type': 'application/json'
        'authorization': 'Bearer '+data.token
    }
})
.then(function(data) {
return data.json()

}).then(result => console.log(result))

与本文相关的文章

发布评论

评论列表 (0)

  1. 暂无评论