【问题标题】:Link Header Pagination - Dribbble API链接标题分页 - Dribbble API
【发布时间】:2023-03-02 22:31:01
【问题描述】:

我正在使用 Dribbble API,但我不了解他们关于分页的文档:http://developer.dribbble.com/v1/#pagination

我已尝试研究如何进行设置,但似乎找不到有关如何使用 Link 标头进行设置的信息。这是我现在正在使用的代码,它可以完美地提取最近的 12 张照片,但我对分页感到困惑:

$(document).ready(function() {

var url = 'https://api.dribbble.com/v1/user/shots?per_page=12&access_token=*removed*';
var $content = $('#dribbble');

$.ajax({
    type: 'GET',
    url: url,
    dataType: 'jsonp',
    beforeSend: function() {
        $content.append('<div class="loading"><img src="./img/ajax-loader.gif" width="66" height="66" alt="Loading"></div>');
    },
    complete: function() {
        $('#loading').remove();
    },
    success: function(data) {
        var template = $('#dribbbleTpl').html();
        var html = Mustache.to_html(template, data);
        $('#dribbble').html(html).hide().fadeIn(400);
    },
    fail: function() {
        $content.append('<div class="error">Oops! Our Dribbble feed appears to be down.</div>');
    }
})

});

【问题讨论】:

    标签: api pagination


    【解决方案1】:

    由于您请求的是 jsonp,API 应该返回标头元数据。此标题将包含您的链接数据。如果您没有在响应中看到标头,请尝试将 &amp;callback=foo 添加到您的端点 URL。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-11-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-04
      • 2021-09-11
      • 2020-01-10
      • 2012-04-16
      相关资源
      最近更新 更多