gpt4 book ai didi

ember.js - 伪装和查询参数

转载 作者:行者123 更新时间:2023-12-02 06:09:17 25 4
gpt4 key购买 nike

只要没有查询参数,我就可以成功使用Trek的伪装库。

我现在花了4个小时正式盯着下面的代码,无法正常工作。我正在定义一个似乎未受到攻击的网址。但是,当我查看尚未捕获的 call 时,它将返回与我定义的确切URL在一起!如果有人可以帮助我解决这个问题,那将是很棒的。

我有测试代码:

var server;

module("Check Search Index page", {
setup: function() {
'use strict';

Ember.run(function() {
App.reset();

server = new Pretender(function() {
this.get('/api/v1/holidays.json?display_type=detail&page=1&sort%5Bprice%5D=&sort%5Bname%5D=&sort%5Brating%5D=&filter%5Bduration_min%5D=1&filter%5Bduration_max%5D=32&filter%5Bprice_min%5D=50&filter%5Bprice_max%5D=3800&filter%5Bbus%5D=true&filter%5Bflight%5D=true&filter%5Bself_transportation%5D=true', function (request) {
return [200, {'Content-Type': 'application/json'}, '{"holidays":[{"id":507,"name":"App. Elena"}'];
});
});

server.unhandledRequest = function(verb, path, request) {
console.log("=== BEGIN UNHANDLED REQUEST ===");
console.log('verb: ' + verb);
console.log('path: ' + path);
console.log('request: ' + request);
console.log("=== END UNHANDLED REQUEST ===");
};
});
},

teardown: function() {
'use strict';

server.shutdown();
}
});

test('Search page', function() {
'use strict';

visit('/search/index');
andThen(function() {
ok(find('p:contains("Bepaal uw zoek criteria")').length, 'Search page is showing');
});
});

我在控制台中看到的错误消息:
.=== BEGIN UNHANDLED REQUEST ===
verb: GET
path: /api/v1/holidays.json?display_type=detail&page=1&sort%5Bprice%5D=&sort%5Bname%5D=&sort%5Brating%5D=&filter%5Bduration_min%5D=1&filter%5Bduration_max%5D=32&filter%5Bprice_min%5D=50&filter%5Bprice_max%5D=3800&filter%5Bbus%5D=true&filter%5Bflight%5D=true&filter%5Bself_transportation%5D=true
request: [object Object]
=== END UNHANDLED REQUEST ===

最佳答案

您不应在请求定义中定义查询参数。为了使上面的代码起作用,端点的定义应为:

  server = new Pretender(function() {
this.get('/api/v1/holidays.json?', function (request) {
return [200, {'Content-Type': 'application/json'}, '{"holidays":[{"id":507,"name":"App. Elena"}'];
});
});

关于ember.js - 伪装和查询参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26938182/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com