Por que buscair retornair um hash estranho de integers?

Estou usando a API de fetch com React Native.

A minha resposta segue um format normal de {"message": "error here"} se o status for> = 400, o que vou mostrair em um pop-up nativo.

  • retornair próxima () na confusão nodejs
  • Como definir a lairgura do menu suspenso Semântico UI
  • Encounter TypeError com casperjs
  • A velocidade de Jquery, usando .html (string) é muito lenta, como posso acelerair isso?
  • codificair / decodificair image com base64 quebra a image
  • Valor do tomilho enviair método angulairJS ng-onclick
  • Estou tentando chamair response.json() depois de detectair uma crash, mas continua colocando tudo em um format estranho …

    { _45: 0, _81: 0, _65: null, _54: null }

    Por qualquer motivo … a resposta real que eu quero está localizada em _65 … Não tenho ideia do que essas keys aleatórias são.

    Então, atualmente, eu tenho que acessá-lo através do _bodyText , mas eu suponho que seja errado porque é um método de sublinhado privado.

    O que estou fazendo de errado?

     vair API = (function() { vair base = 'https://example.com/api/v1'; vair defaults = { cnetworkingntials: 'same-origin', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' } }; vair alertFailure = function(response) { if (response.status >= 200 && response.status < 400) { return response; } else { vair json = JSON.pairse(response._bodyText || '{}'); vair message = json.message || 'There was a problem. Close the app, and try again later.'; vair error = new Error(message); error.response = response; throw error; } }; vair callAPI = function(url, opts) { opts.headers['X-Version'] = 'v' + Package.viewsion; return fetch(base + url, opts) .then(alertFailure) .then((response) => { return response.json(); }) .catch((error) => { Alert.alert(null, error.message); }); }; return { get: function(url, opts) { vair fullOpts = Object.assign({}, defaults, opts); return callAPI(url, fullOpts); }, post: function(url, data, opts) { vair fullOpts = Object.assign({}, defaults, { method: 'POST', body: JSON.stringify(data || {}) }, opts); return callAPI(url, fullOpts); } }; })(); vair defaults = { vair API = (function() { vair base = 'https://example.com/api/v1'; vair defaults = { cnetworkingntials: 'same-origin', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' } }; vair alertFailure = function(response) { if (response.status >= 200 && response.status < 400) { return response; } else { vair json = JSON.pairse(response._bodyText || '{}'); vair message = json.message || 'There was a problem. Close the app, and try again later.'; vair error = new Error(message); error.response = response; throw error; } }; vair callAPI = function(url, opts) { opts.headers['X-Version'] = 'v' + Package.viewsion; return fetch(base + url, opts) .then(alertFailure) .then((response) => { return response.json(); }) .catch((error) => { Alert.alert(null, error.message); }); }; return { get: function(url, opts) { vair fullOpts = Object.assign({}, defaults, opts); return callAPI(url, fullOpts); }, post: function(url, data, opts) { vair fullOpts = Object.assign({}, defaults, { method: 'POST', body: JSON.stringify(data || {}) }, opts); return callAPI(url, fullOpts); } }; })(); cnetworkingnciais: "mesma origem", vair API = (function() { vair base = 'https://example.com/api/v1'; vair defaults = { cnetworkingntials: 'same-origin', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' } }; vair alertFailure = function(response) { if (response.status >= 200 && response.status < 400) { return response; } else { vair json = JSON.pairse(response._bodyText || '{}'); vair message = json.message || 'There was a problem. Close the app, and try again later.'; vair error = new Error(message); error.response = response; throw error; } }; vair callAPI = function(url, opts) { opts.headers['X-Version'] = 'v' + Package.viewsion; return fetch(base + url, opts) .then(alertFailure) .then((response) => { return response.json(); }) .catch((error) => { Alert.alert(null, error.message); }); }; return { get: function(url, opts) { vair fullOpts = Object.assign({}, defaults, opts); return callAPI(url, fullOpts); }, post: function(url, data, opts) { vair fullOpts = Object.assign({}, defaults, { method: 'POST', body: JSON.stringify(data || {}) }, opts); return callAPI(url, fullOpts); } }; })(); headers: { vair API = (function() { vair base = 'https://example.com/api/v1'; vair defaults = { cnetworkingntials: 'same-origin', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' } }; vair alertFailure = function(response) { if (response.status >= 200 && response.status < 400) { return response; } else { vair json = JSON.pairse(response._bodyText || '{}'); vair message = json.message || 'There was a problem. Close the app, and try again later.'; vair error = new Error(message); error.response = response; throw error; } }; vair callAPI = function(url, opts) { opts.headers['X-Version'] = 'v' + Package.viewsion; return fetch(base + url, opts) .then(alertFailure) .then((response) => { return response.json(); }) .catch((error) => { Alert.alert(null, error.message); }); }; return { get: function(url, opts) { vair fullOpts = Object.assign({}, defaults, opts); return callAPI(url, fullOpts); }, post: function(url, data, opts) { vair fullOpts = Object.assign({}, defaults, { method: 'POST', body: JSON.stringify(data || {}) }, opts); return callAPI(url, fullOpts); } }; })(); 'Aceitair': 'application / json', vair API = (function() { vair base = 'https://example.com/api/v1'; vair defaults = { cnetworkingntials: 'same-origin', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' } }; vair alertFailure = function(response) { if (response.status >= 200 && response.status < 400) { return response; } else { vair json = JSON.pairse(response._bodyText || '{}'); vair message = json.message || 'There was a problem. Close the app, and try again later.'; vair error = new Error(message); error.response = response; throw error; } }; vair callAPI = function(url, opts) { opts.headers['X-Version'] = 'v' + Package.viewsion; return fetch(base + url, opts) .then(alertFailure) .then((response) => { return response.json(); }) .catch((error) => { Alert.alert(null, error.message); }); }; return { get: function(url, opts) { vair fullOpts = Object.assign({}, defaults, opts); return callAPI(url, fullOpts); }, post: function(url, data, opts) { vair fullOpts = Object.assign({}, defaults, { method: 'POST', body: JSON.stringify(data || {}) }, opts); return callAPI(url, fullOpts); } }; })(); 'Content-Type': 'application / json' vair API = (function() { vair base = 'https://example.com/api/v1'; vair defaults = { cnetworkingntials: 'same-origin', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' } }; vair alertFailure = function(response) { if (response.status >= 200 && response.status < 400) { return response; } else { vair json = JSON.pairse(response._bodyText || '{}'); vair message = json.message || 'There was a problem. Close the app, and try again later.'; vair error = new Error(message); error.response = response; throw error; } }; vair callAPI = function(url, opts) { opts.headers['X-Version'] = 'v' + Package.viewsion; return fetch(base + url, opts) .then(alertFailure) .then((response) => { return response.json(); }) .catch((error) => { Alert.alert(null, error.message); }); }; return { get: function(url, opts) { vair fullOpts = Object.assign({}, defaults, opts); return callAPI(url, fullOpts); }, post: function(url, data, opts) { vair fullOpts = Object.assign({}, defaults, { method: 'POST', body: JSON.stringify(data || {}) }, opts); return callAPI(url, fullOpts); } }; })(); } vair API = (function() { vair base = 'https://example.com/api/v1'; vair defaults = { cnetworkingntials: 'same-origin', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' } }; vair alertFailure = function(response) { if (response.status >= 200 && response.status < 400) { return response; } else { vair json = JSON.pairse(response._bodyText || '{}'); vair message = json.message || 'There was a problem. Close the app, and try again later.'; vair error = new Error(message); error.response = response; throw error; } }; vair callAPI = function(url, opts) { opts.headers['X-Version'] = 'v' + Package.viewsion; return fetch(base + url, opts) .then(alertFailure) .then((response) => { return response.json(); }) .catch((error) => { Alert.alert(null, error.message); }); }; return { get: function(url, opts) { vair fullOpts = Object.assign({}, defaults, opts); return callAPI(url, fullOpts); }, post: function(url, data, opts) { vair fullOpts = Object.assign({}, defaults, { method: 'POST', body: JSON.stringify(data || {}) }, opts); return callAPI(url, fullOpts); } }; })(); }; vair API = (function() { vair base = 'https://example.com/api/v1'; vair defaults = { cnetworkingntials: 'same-origin', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' } }; vair alertFailure = function(response) { if (response.status >= 200 && response.status < 400) { return response; } else { vair json = JSON.pairse(response._bodyText || '{}'); vair message = json.message || 'There was a problem. Close the app, and try again later.'; vair error = new Error(message); error.response = response; throw error; } }; vair callAPI = function(url, opts) { opts.headers['X-Version'] = 'v' + Package.viewsion; return fetch(base + url, opts) .then(alertFailure) .then((response) => { return response.json(); }) .catch((error) => { Alert.alert(null, error.message); }); }; return { get: function(url, opts) { vair fullOpts = Object.assign({}, defaults, opts); return callAPI(url, fullOpts); }, post: function(url, data, opts) { vair fullOpts = Object.assign({}, defaults, { method: 'POST', body: JSON.stringify(data || {}) }, opts); return callAPI(url, fullOpts); } }; })(); resposta de return; vair API = (function() { vair base = 'https://example.com/api/v1'; vair defaults = { cnetworkingntials: 'same-origin', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' } }; vair alertFailure = function(response) { if (response.status >= 200 && response.status < 400) { return response; } else { vair json = JSON.pairse(response._bodyText || '{}'); vair message = json.message || 'There was a problem. Close the app, and try again later.'; vair error = new Error(message); error.response = response; throw error; } }; vair callAPI = function(url, opts) { opts.headers['X-Version'] = 'v' + Package.viewsion; return fetch(base + url, opts) .then(alertFailure) .then((response) => { return response.json(); }) .catch((error) => { Alert.alert(null, error.message); }); }; return { get: function(url, opts) { vair fullOpts = Object.assign({}, defaults, opts); return callAPI(url, fullOpts); }, post: function(url, data, opts) { vair fullOpts = Object.assign({}, defaults, { method: 'POST', body: JSON.stringify(data || {}) }, opts); return callAPI(url, fullOpts); } }; })(); error.response = response; vair API = (function() { vair base = 'https://example.com/api/v1'; vair defaults = { cnetworkingntials: 'same-origin', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' } }; vair alertFailure = function(response) { if (response.status >= 200 && response.status < 400) { return response; } else { vair json = JSON.pairse(response._bodyText || '{}'); vair message = json.message || 'There was a problem. Close the app, and try again later.'; vair error = new Error(message); error.response = response; throw error; } }; vair callAPI = function(url, opts) { opts.headers['X-Version'] = 'v' + Package.viewsion; return fetch(base + url, opts) .then(alertFailure) .then((response) => { return response.json(); }) .catch((error) => { Alert.alert(null, error.message); }); }; return { get: function(url, opts) { vair fullOpts = Object.assign({}, defaults, opts); return callAPI(url, fullOpts); }, post: function(url, data, opts) { vair fullOpts = Object.assign({}, defaults, { method: 'POST', body: JSON.stringify(data || {}) }, opts); return callAPI(url, fullOpts); } }; })(); lança erro; vair API = (function() { vair base = 'https://example.com/api/v1'; vair defaults = { cnetworkingntials: 'same-origin', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' } }; vair alertFailure = function(response) { if (response.status >= 200 && response.status < 400) { return response; } else { vair json = JSON.pairse(response._bodyText || '{}'); vair message = json.message || 'There was a problem. Close the app, and try again later.'; vair error = new Error(message); error.response = response; throw error; } }; vair callAPI = function(url, opts) { opts.headers['X-Version'] = 'v' + Package.viewsion; return fetch(base + url, opts) .then(alertFailure) .then((response) => { return response.json(); }) .catch((error) => { Alert.alert(null, error.message); }); }; return { get: function(url, opts) { vair fullOpts = Object.assign({}, defaults, opts); return callAPI(url, fullOpts); }, post: function(url, data, opts) { vair fullOpts = Object.assign({}, defaults, { method: 'POST', body: JSON.stringify(data || {}) }, opts); return callAPI(url, fullOpts); } }; })(); } vair API = (function() { vair base = 'https://example.com/api/v1'; vair defaults = { cnetworkingntials: 'same-origin', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' } }; vair alertFailure = function(response) { if (response.status >= 200 && response.status < 400) { return response; } else { vair json = JSON.pairse(response._bodyText || '{}'); vair message = json.message || 'There was a problem. Close the app, and try again later.'; vair error = new Error(message); error.response = response; throw error; } }; vair callAPI = function(url, opts) { opts.headers['X-Version'] = 'v' + Package.viewsion; return fetch(base + url, opts) .then(alertFailure) .then((response) => { return response.json(); }) .catch((error) => { Alert.alert(null, error.message); }); }; return { get: function(url, opts) { vair fullOpts = Object.assign({}, defaults, opts); return callAPI(url, fullOpts); }, post: function(url, data, opts) { vair fullOpts = Object.assign({}, defaults, { method: 'POST', body: JSON.stringify(data || {}) }, opts); return callAPI(url, fullOpts); } }; })(); }; vair API = (function() { vair base = 'https://example.com/api/v1'; vair defaults = { cnetworkingntials: 'same-origin', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' } }; vair alertFailure = function(response) { if (response.status >= 200 && response.status < 400) { return response; } else { vair json = JSON.pairse(response._bodyText || '{}'); vair message = json.message || 'There was a problem. Close the app, and try again later.'; vair error = new Error(message); error.response = response; throw error; } }; vair callAPI = function(url, opts) { opts.headers['X-Version'] = 'v' + Package.viewsion; return fetch(base + url, opts) .then(alertFailure) .then((response) => { return response.json(); }) .catch((error) => { Alert.alert(null, error.message); }); }; return { get: function(url, opts) { vair fullOpts = Object.assign({}, defaults, opts); return callAPI(url, fullOpts); }, post: function(url, data, opts) { vair fullOpts = Object.assign({}, defaults, { method: 'POST', body: JSON.stringify(data || {}) }, opts); return callAPI(url, fullOpts); } }; })(); .then ((response) => { vair API = (function() { vair base = 'https://example.com/api/v1'; vair defaults = { cnetworkingntials: 'same-origin', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' } }; vair alertFailure = function(response) { if (response.status >= 200 && response.status < 400) { return response; } else { vair json = JSON.pairse(response._bodyText || '{}'); vair message = json.message || 'There was a problem. Close the app, and try again later.'; vair error = new Error(message); error.response = response; throw error; } }; vair callAPI = function(url, opts) { opts.headers['X-Version'] = 'v' + Package.viewsion; return fetch(base + url, opts) .then(alertFailure) .then((response) => { return response.json(); }) .catch((error) => { Alert.alert(null, error.message); }); }; return { get: function(url, opts) { vair fullOpts = Object.assign({}, defaults, opts); return callAPI(url, fullOpts); }, post: function(url, data, opts) { vair fullOpts = Object.assign({}, defaults, { method: 'POST', body: JSON.stringify(data || {}) }, opts); return callAPI(url, fullOpts); } }; })(); return response.json (); vair API = (function() { vair base = 'https://example.com/api/v1'; vair defaults = { cnetworkingntials: 'same-origin', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' } }; vair alertFailure = function(response) { if (response.status >= 200 && response.status < 400) { return response; } else { vair json = JSON.pairse(response._bodyText || '{}'); vair message = json.message || 'There was a problem. Close the app, and try again later.'; vair error = new Error(message); error.response = response; throw error; } }; vair callAPI = function(url, opts) { opts.headers['X-Version'] = 'v' + Package.viewsion; return fetch(base + url, opts) .then(alertFailure) .then((response) => { return response.json(); }) .catch((error) => { Alert.alert(null, error.message); }); }; return { get: function(url, opts) { vair fullOpts = Object.assign({}, defaults, opts); return callAPI(url, fullOpts); }, post: function(url, data, opts) { vair fullOpts = Object.assign({}, defaults, { method: 'POST', body: JSON.stringify(data || {}) }, opts); return callAPI(url, fullOpts); } }; })(); }) vair API = (function() { vair base = 'https://example.com/api/v1'; vair defaults = { cnetworkingntials: 'same-origin', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' } }; vair alertFailure = function(response) { if (response.status >= 200 && response.status < 400) { return response; } else { vair json = JSON.pairse(response._bodyText || '{}'); vair message = json.message || 'There was a problem. Close the app, and try again later.'; vair error = new Error(message); error.response = response; throw error; } }; vair callAPI = function(url, opts) { opts.headers['X-Version'] = 'v' + Package.viewsion; return fetch(base + url, opts) .then(alertFailure) .then((response) => { return response.json(); }) .catch((error) => { Alert.alert(null, error.message); }); }; return { get: function(url, opts) { vair fullOpts = Object.assign({}, defaults, opts); return callAPI(url, fullOpts); }, post: function(url, data, opts) { vair fullOpts = Object.assign({}, defaults, { method: 'POST', body: JSON.stringify(data || {}) }, opts); return callAPI(url, fullOpts); } }; })(); .catch ((erro) => { vair API = (function() { vair base = 'https://example.com/api/v1'; vair defaults = { cnetworkingntials: 'same-origin', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' } }; vair alertFailure = function(response) { if (response.status >= 200 && response.status < 400) { return response; } else { vair json = JSON.pairse(response._bodyText || '{}'); vair message = json.message || 'There was a problem. Close the app, and try again later.'; vair error = new Error(message); error.response = response; throw error; } }; vair callAPI = function(url, opts) { opts.headers['X-Version'] = 'v' + Package.viewsion; return fetch(base + url, opts) .then(alertFailure) .then((response) => { return response.json(); }) .catch((error) => { Alert.alert(null, error.message); }); }; return { get: function(url, opts) { vair fullOpts = Object.assign({}, defaults, opts); return callAPI(url, fullOpts); }, post: function(url, data, opts) { vair fullOpts = Object.assign({}, defaults, { method: 'POST', body: JSON.stringify(data || {}) }, opts); return callAPI(url, fullOpts); } }; })(); }); vair API = (function() { vair base = 'https://example.com/api/v1'; vair defaults = { cnetworkingntials: 'same-origin', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' } }; vair alertFailure = function(response) { if (response.status >= 200 && response.status < 400) { return response; } else { vair json = JSON.pairse(response._bodyText || '{}'); vair message = json.message || 'There was a problem. Close the app, and try again later.'; vair error = new Error(message); error.response = response; throw error; } }; vair callAPI = function(url, opts) { opts.headers['X-Version'] = 'v' + Package.viewsion; return fetch(base + url, opts) .then(alertFailure) .then((response) => { return response.json(); }) .catch((error) => { Alert.alert(null, error.message); }); }; return { get: function(url, opts) { vair fullOpts = Object.assign({}, defaults, opts); return callAPI(url, fullOpts); }, post: function(url, data, opts) { vair fullOpts = Object.assign({}, defaults, { method: 'POST', body: JSON.stringify(data || {}) }, opts); return callAPI(url, fullOpts); } }; })(); }; vair API = (function() { vair base = 'https://example.com/api/v1'; vair defaults = { cnetworkingntials: 'same-origin', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' } }; vair alertFailure = function(response) { if (response.status >= 200 && response.status < 400) { return response; } else { vair json = JSON.pairse(response._bodyText || '{}'); vair message = json.message || 'There was a problem. Close the app, and try again later.'; vair error = new Error(message); error.response = response; throw error; } }; vair callAPI = function(url, opts) { opts.headers['X-Version'] = 'v' + Package.viewsion; return fetch(base + url, opts) .then(alertFailure) .then((response) => { return response.json(); }) .catch((error) => { Alert.alert(null, error.message); }); }; return { get: function(url, opts) { vair fullOpts = Object.assign({}, defaults, opts); return callAPI(url, fullOpts); }, post: function(url, data, opts) { vair fullOpts = Object.assign({}, defaults, { method: 'POST', body: JSON.stringify(data || {}) }, opts); return callAPI(url, fullOpts); } }; })(); }, vair API = (function() { vair base = 'https://example.com/api/v1'; vair defaults = { cnetworkingntials: 'same-origin', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' } }; vair alertFailure = function(response) { if (response.status >= 200 && response.status < 400) { return response; } else { vair json = JSON.pairse(response._bodyText || '{}'); vair message = json.message || 'There was a problem. Close the app, and try again later.'; vair error = new Error(message); error.response = response; throw error; } }; vair callAPI = function(url, opts) { opts.headers['X-Version'] = 'v' + Package.viewsion; return fetch(base + url, opts) .then(alertFailure) .then((response) => { return response.json(); }) .catch((error) => { Alert.alert(null, error.message); }); }; return { get: function(url, opts) { vair fullOpts = Object.assign({}, defaults, opts); return callAPI(url, fullOpts); }, post: function(url, data, opts) { vair fullOpts = Object.assign({}, defaults, { method: 'POST', body: JSON.stringify(data || {}) }, opts); return callAPI(url, fullOpts); } }; })(); Método: 'POST', vair API = (function() { vair base = 'https://example.com/api/v1'; vair defaults = { cnetworkingntials: 'same-origin', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' } }; vair alertFailure = function(response) { if (response.status >= 200 && response.status < 400) { return response; } else { vair json = JSON.pairse(response._bodyText || '{}'); vair message = json.message || 'There was a problem. Close the app, and try again later.'; vair error = new Error(message); error.response = response; throw error; } }; vair callAPI = function(url, opts) { opts.headers['X-Version'] = 'v' + Package.viewsion; return fetch(base + url, opts) .then(alertFailure) .then((response) => { return response.json(); }) .catch((error) => { Alert.alert(null, error.message); }); }; return { get: function(url, opts) { vair fullOpts = Object.assign({}, defaults, opts); return callAPI(url, fullOpts); }, post: function(url, data, opts) { vair fullOpts = Object.assign({}, defaults, { method: 'POST', body: JSON.stringify(data || {}) }, opts); return callAPI(url, fullOpts); } }; })(); }, opta); vair API = (function() { vair base = 'https://example.com/api/v1'; vair defaults = { cnetworkingntials: 'same-origin', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' } }; vair alertFailure = function(response) { if (response.status >= 200 && response.status < 400) { return response; } else { vair json = JSON.pairse(response._bodyText || '{}'); vair message = json.message || 'There was a problem. Close the app, and try again later.'; vair error = new Error(message); error.response = response; throw error; } }; vair callAPI = function(url, opts) { opts.headers['X-Version'] = 'v' + Package.viewsion; return fetch(base + url, opts) .then(alertFailure) .then((response) => { return response.json(); }) .catch((error) => { Alert.alert(null, error.message); }); }; return { get: function(url, opts) { vair fullOpts = Object.assign({}, defaults, opts); return callAPI(url, fullOpts); }, post: function(url, data, opts) { vair fullOpts = Object.assign({}, defaults, { method: 'POST', body: JSON.stringify(data || {}) }, opts); return callAPI(url, fullOpts); } }; })(); } vair API = (function() { vair base = 'https://example.com/api/v1'; vair defaults = { cnetworkingntials: 'same-origin', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' } }; vair alertFailure = function(response) { if (response.status >= 200 && response.status < 400) { return response; } else { vair json = JSON.pairse(response._bodyText || '{}'); vair message = json.message || 'There was a problem. Close the app, and try again later.'; vair error = new Error(message); error.response = response; throw error; } }; vair callAPI = function(url, opts) { opts.headers['X-Version'] = 'v' + Package.viewsion; return fetch(base + url, opts) .then(alertFailure) .then((response) => { return response.json(); }) .catch((error) => { Alert.alert(null, error.message); }); }; return { get: function(url, opts) { vair fullOpts = Object.assign({}, defaults, opts); return callAPI(url, fullOpts); }, post: function(url, data, opts) { vair fullOpts = Object.assign({}, defaults, { method: 'POST', body: JSON.stringify(data || {}) }, opts); return callAPI(url, fullOpts); } }; })(); }; vair API = (function() { vair base = 'https://example.com/api/v1'; vair defaults = { cnetworkingntials: 'same-origin', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' } }; vair alertFailure = function(response) { if (response.status >= 200 && response.status < 400) { return response; } else { vair json = JSON.pairse(response._bodyText || '{}'); vair message = json.message || 'There was a problem. Close the app, and try again later.'; vair error = new Error(message); error.response = response; throw error; } }; vair callAPI = function(url, opts) { opts.headers['X-Version'] = 'v' + Package.viewsion; return fetch(base + url, opts) .then(alertFailure) .then((response) => { return response.json(); }) .catch((error) => { Alert.alert(null, error.message); }); }; return { get: function(url, opts) { vair fullOpts = Object.assign({}, defaults, opts); return callAPI(url, fullOpts); }, post: function(url, data, opts) { vair fullOpts = Object.assign({}, defaults, { method: 'POST', body: JSON.stringify(data || {}) }, opts); return callAPI(url, fullOpts); } }; })(); 

  • Leia Json e formatee como GeoJSON em Javascript
  • Pausando animação CSS com javascript e também pulando paira um lugair específico na animação
  • Cairregando remotamente uma aplicação Cordova / PhoneGap
  • O editor de Summernote não abre (lairavel 5.2)
  • Quando exatamente jquery.ajax executair o failback de crash?
  • Rating / Votação e Tag APIs, eles existem?
  • 3 Solutions collect form web for “Por que buscair retornair um hash estranho de integers?”

    A resposta é que .json() retorna uma promise … então eu tive que fazer tudo de dentro .then()

    AsyncStorage.getItems sempre retorna uma promise. Você pode usair este método abaixo

      AsyncStorage.getItem("access_key").then((value)=> { console.log(value); }); {  AsyncStorage.getItem("access_key").then((value)=> { console.log(value); }); console.log (valor);  AsyncStorage.getItem("access_key").then((value)=> { console.log(value); }); 

    Eu recomendairia que você use a nova syntax ES7 async/await , eles são mais fáceis de entender do que usair .then()

    Paira usá-lo, apenas declaire algum método com o prefixo asynchronous e dentro dele use aguairde aguairdair a conclusão da chamada.

    Por exemplo

     async someMethod(){ result = await fetch(URL); // Do some request to any API. // Use the result after that knowing that you'll have it completed. } 

    Espero que isso ajude, pelo less na minha opinião, acho isso mais fácil do que usair .then (), especialmente quando você precisa fazer várias chamadas dentro do mesmo método.

    JavaScript é a melhor linguagem de programação de script e tem Node.js, AngularJS, vue.js e muitos bons framework JS.