11-13-2018 19:56
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

Recovery Runner
8
0
0
11-13-2018 19:56
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
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/cors
And 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

1 REPLY 1
11-14-2018 12:43
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


Fitbit Developer
2266
575
1162
11-14-2018 12:43
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Looks like you're pretty much there, you've just omitted to pass the options into the fetch().
fetch(url, opts).then(

