如何使用JavaScript,jQuery或Ajax从FireFox控制台中的Request标头访问数据?

时间:2017-11-16 20:34:24

标签: jquery ajax firefox token

var cities = [
  ['123456789', 'City1']
]

var keyValue = document.cookie.match('(^|;) ?' + token + '=([^;]*)(;|$)');
var token = keyValue ? keyValue[2] : null;



$.ajax({
  url: 'http://webserver/userportal/api/rest/content/archives/-1/page?ownerPublic=2&page=0&pageSize=10&isTrash=false&durationVal=0&durationOpt=-1',
  method: 'GET',
  headers: {
    'Accept': 'application/vnd.plcm.plcm-content-archive+json',
    'Authorization': 'Bearer anonymous',
    token: '3a90f457e9774382bd8202af85f1b4741510863389858', // i hard coded this because I can't figure out how to get it from the Request header
    'Cache-Control': 'no-cache',
    Pragma: 'no-cache'
  }
})
  .then(function (response) {
    console.log(response)
    $("div.displayname div").each(function (index) {
      var title = $(this).attr('title')
      var titleDate = ''


      vicenages.forEach(function (vicenage) {
        if (title.indexOf(vicenage[0]) > -1) {
          var datePart = title.split('_')[2]
          var year = datePart.substr(0, 4)
          var month = datePart.substr(4, 2)
          var day = datePart.substr(6, 2)
          var dayString = month + '-' + day + '-' + year

          var newFileName = vicenage[1] + ' ' + dayString

          $.ajax({
            url: '/url',
            method: 'PUT'
          })

          console.log(title, newFileName)
        }
      })
    })

  })

我无法从请求标头中获取令牌。我只在FireFox开发者控制台中运行我的代码。

我正在尝试访问这些项目

Host
User-Agent
Accept
Accept-Language
Cache-Control
If-Modified-Since
token
Authorization
Referer
Cookie
Connection

0 个答案:

没有答案