)]}'
{"doc/source/specs/server_interaction.rst":[{"author":{"_account_id":13516,"name":"Anton Zemlyanov","email":"azemlyanov@mirantis.com","username":"azemlyanov"},"change_message_id":"d1fee2b2a0efb595f02ef61cedd0578f5b360bb5","unresolved":false,"context_lines":[{"line_number":57,"context_line":""},{"line_number":58,"context_line":"Implementation"},{"line_number":59,"context_line":"\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d"},{"line_number":60,"context_line":""},{"line_number":61,"context_line":"Assignee(s)"},{"line_number":62,"context_line":"-----------"},{"line_number":63,"context_line":""}],"source_content_type":"text/x-rst","patch_set":1,"id":"3aaa91ec_4e3fc886","line":60,"updated":"2016-07-01 07:59:09.000000000","message":"No implementation yet. Will it be generic http stuff or openstack-specific module?\n\nMy experience with fetch API is it\u0027s very generic and there should be simpler API for special cases. There should not be any streaming for response body - just call me back or resolve promise when full response is there and parsed.\n\nThe code example working with fetch looks like this\n\n    _request(method, params, cb \u003d () \u003d\u003e {}) {\n        let req \u003d {\n            jsonrpc: \u00272.0\u0027,\n            id: this.nextId++,\n            method,\n            params\n        };\n        return fetch(ENDPOINT + \u0027/\u0027 + method, {\n            headers: new Headers({\u0027Content-Type\u0027: \u0027application/json\u0027}),\n            method: \u0027POST\u0027,\n            body: JSON.stringify(req)\n        }).then((response) \u003d\u003e {\n            if (!response.ok) {\n                cb(response.statusText);\n                return;\n            }\n            response.json()\n                .then((json) \u003d\u003e {\n                    cb(json.error, json.result)\n                })\n                .catch((error)\u003d\u003e {\n                    cb(error);\n                });\n        }).catch((error) \u003d\u003e {\n            cb(error);\n        });\n    }\n\nI suggest supporting both Promises and callback style. If user provide callback - it is called, if no - then he should rely on returned promise:\n\napi.invoke(request, () \u003d\u003e {....})\n\nor\n\nlet result \u003d api.invoke(request)\nresult.then(...)\n\nin rare case there is fire and forget:\n\napi.invoke(request)","commit_id":"74b664e0591186ad9e394f87ce2ec4762d1524c4"},{"author":{"_account_id":8735,"name":"Vitaly Kramskikh","email":"vkramskikh@mirantis.com","username":"vkramskikh"},"change_message_id":"e448542a1eea0664eda87b09856fc43bd96cce91","unresolved":false,"context_lines":[{"line_number":57,"context_line":""},{"line_number":58,"context_line":"Implementation"},{"line_number":59,"context_line":"\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d"},{"line_number":60,"context_line":""},{"line_number":61,"context_line":"Assignee(s)"},{"line_number":62,"context_line":"-----------"},{"line_number":63,"context_line":""}],"source_content_type":"text/x-rst","patch_set":1,"id":"1aa78d24_504c3c70","line":60,"in_reply_to":"3aaa91ec_4e3fc886","updated":"2016-07-04 13:45:29.000000000","message":"Anton,\n\nI thought about creating some wrapper to simplify the interface, but soon figured out that it\u0027s not really needed - fetch() interface is simple enough, so this spec proposes to use fetch() directly.\n\nWe\u0027ll probably need some wrapper later to support request caching/throttling/something else, but this should be done in a separate spec. For now we can go with pure fetch().","commit_id":"74b664e0591186ad9e394f87ce2ec4762d1524c4"}]}
