Okay, so basically you need another one then. So this is due to promises. I realized this after reading this wonderful article http://blog.gospodarets.com/fetch_in_action/
What you need to do is
var getObject = function { var url = "https://api.parse.com"; url += '/1/classes/birthday'; return fetch(url, { method: 'GET', headers: { 'Accept': 'application/json', 'X-Parse-Application-Id': '12122', 'X-Parse-REST-API-Key': '12121', 'Content-Type': 'application/json', }, data: '{"where":{"uid":"12312312"}}' }) .then(function(response) { return response.text(); }) .then(function(data){ console.log(data);
I do not understand why you need to return response.text (). Again, this is something to do promises
https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Promise
Because when I access response.text () from the first, then. He returns the promise.
I hope some other kind gentleman can comment and explain why returning response.text () turns the promise into the data you need.
- EDIT -
I added a few returns to show how you can getObject to return the response data as an object. So,
var d = getObject();
will return the response as a js object.
source share