不匹配的字符 ' ' 期待 '\"'
mismatched character ' ' expecting '\"'
我正在向代理发送请求,但出现此错误:
{"error":{"lang":"en-US","description":"Query syntax error(s) [line 1:68 mismatched character ' ' expecting '\"']"}}
这是URL:
https://query.yahooapis.com/v1/public/yql?q=SELECT%20*%20FROM%20json%20WHERE%20url=%22https://1ex.trade/api/stats?market=BTC¤cy=CHBT%22&format=json
有人知道我做错了什么吗?
这是我在 JS 中的请求
let fetchRequestForGettingTheNamesTroughProxy = function (exchangeUrl) {
return new Promise(function (resolve, reject) {
const url = exchangeUrl;
const yql_url = 'https://query.yahooapis.com/v1/public/yql?q=' + 'SELECT * FROM json WHERE url="' + url + '"&format=json';
let request = new Request(yql_url, {
method: 'POST',
headers: new Headers()
});
fetch(request)
.then((resp) => resp.json())
.then(function (data) {
console.log(data.query.results);
if (data.query.results === null){
fetchRequestForGettingTheNamesTroughProxy(exchangeUrl);
} else{
resolve(data.query.results.json);
}
});
});
};
你没有正确编码你的 url 它应该看起来像
https://query.yahooapis.com/v1/public/yql?q=SELECT%20*%20FROM%20json%20WHERE%20url=%27https%3A%2F%2F1ex.trade%2Fapi%2Fstats%3Fmarket%3DBTC%26currency%3DCHBT%27&format=json
const yql_url = 'https://query.yahooapis.com/v1/public/yql?q=' + 'SELECT * FROM json WHERE url="' + encodeURIComponent(url) + '"&format=json';
我认为您需要正确编码 url 参数
exchangeUrl
中的与号 (&) 破坏了 q
参数,因此破坏了您的查询。
const yql_url = 'https://query.yahooapis.com/v1/public/yql?q=' +
'SELECT * FROM json WHERE url="' + encodeURIComponent(url) +
'"&format=json';
你的 q URL 中的 & 需要编码。
EG:
https://query.yahooapis.com/v1/public/yql?q=SELECT%20*%20FROM%20json%20WHERE%20url=%22https://1ex.trade/api/stats?market=BTC%26currency=CHBT%22&format=json
我正在向代理发送请求,但出现此错误:
{"error":{"lang":"en-US","description":"Query syntax error(s) [line 1:68 mismatched character ' ' expecting '\"']"}}
这是URL:
https://query.yahooapis.com/v1/public/yql?q=SELECT%20*%20FROM%20json%20WHERE%20url=%22https://1ex.trade/api/stats?market=BTC¤cy=CHBT%22&format=json
有人知道我做错了什么吗?
这是我在 JS 中的请求
let fetchRequestForGettingTheNamesTroughProxy = function (exchangeUrl) {
return new Promise(function (resolve, reject) {
const url = exchangeUrl;
const yql_url = 'https://query.yahooapis.com/v1/public/yql?q=' + 'SELECT * FROM json WHERE url="' + url + '"&format=json';
let request = new Request(yql_url, {
method: 'POST',
headers: new Headers()
});
fetch(request)
.then((resp) => resp.json())
.then(function (data) {
console.log(data.query.results);
if (data.query.results === null){
fetchRequestForGettingTheNamesTroughProxy(exchangeUrl);
} else{
resolve(data.query.results.json);
}
});
});
};
你没有正确编码你的 url 它应该看起来像
https://query.yahooapis.com/v1/public/yql?q=SELECT%20*%20FROM%20json%20WHERE%20url=%27https%3A%2F%2F1ex.trade%2Fapi%2Fstats%3Fmarket%3DBTC%26currency%3DCHBT%27&format=json
const yql_url = 'https://query.yahooapis.com/v1/public/yql?q=' + 'SELECT * FROM json WHERE url="' + encodeURIComponent(url) + '"&format=json';
我认为您需要正确编码 url 参数
exchangeUrl
中的与号 (&) 破坏了 q
参数,因此破坏了您的查询。
const yql_url = 'https://query.yahooapis.com/v1/public/yql?q=' +
'SELECT * FROM json WHERE url="' + encodeURIComponent(url) +
'"&format=json';
你的 q URL 中的 & 需要编码。
EG:
https://query.yahooapis.com/v1/public/yql?q=SELECT%20*%20FROM%20json%20WHERE%20url=%22https://1ex.trade/api/stats?market=BTC%26currency=CHBT%22&format=json