Я разрабатываю веб-приложение, используя node.js и express.js.
Вот рабочая команда cURL, которую я хотел бы преобразовать в javascript, используя модуль node-fetch
.
curl -X GET -H "X-Parse-Application-Id: APPLICATION_ID" -H "X-Parse-REST-API-Key: restAPIKey" -G --data-urlencode "count=1" --data-urlencode "limit=0" http://localhost:1337/parse/classes/GCUR_LOCATION
Как получить параметры data-urlencode в следующий фрагмент, чтобы завершить работу javascript для выполнения этой работы?
fetch('http://localhost:1337/parse/classes/GCUR_LOCATION', { method: 'GET', headers: {
'X-Parse-Application-Id': 'APPLICATION_ID',
'X-Parse-REST-API-Key': 'restAPIKey'
}});
Используйте querystring
.
const querystring = require('querystring');
const query = querystring.stringify({ count: 1, limit: 0 });
const url = 'http://localhost:1337/parse/classes/GCUR_LOCATION?${query}';
fetch(url, {
method: 'GET',
headers: {
'X-Parse-Application-Id': 'APPLICATION_ID',
'X-Parse-REST-API-Key': 'restAPIKey'
}
});