11-13-2018 19:56
11-13-2018 19:56
Hi! I'm trying to make a simple request with fetch but I have some difficulty to have a response.
I try to convert this example create for CURL :
curl -v -u 1971800d4d82861d8f2c1651fea4d212:api_token \
-H "Content-Type: application/json" \
-d '{"domain":"url.com"}' \
-X POST https://www.toggl.com/api/v9/me/corsAnd my version for the companion app :
const headers = {
'Accept': 'application/json',
'Auth' : {
'user': '87129847189471242ennenbe21test',
'pass': 'api_token'
}
}
const url = 'https://www.toggl.com/api/v8/me';
const opts = {headers: headers, 'Method' : 'POST'};
function queryDataPrint() {
fetch(url).then(function (response) {
response.json()
.then(function(data) {
if (peerSocket.readyState === peerSocket.OPEN) {
console.log(JSON.stringify(data));
}
});
})
.catch(function (err) {
console.log("Error fetching data : " + err);
});
}A little idea of where I can make my mistake? Thank in advance
Best Answer11-14-2018 12:43
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
11-14-2018 12:43
Looks like you're pretty much there, you've just omitted to pass the options into the fetch().
fetch(url, opts).then(
Best Answer