Posts

Showing posts with the label json

JSON Streaming in React Native

I'm building a React Native app that has to listen on a JSON stream, something similar to node's JSONStream/EventStream style (https://www.npmjs.com/package/JSONStream) . Packages like JSONStream can't get imported into React Native due to platform issues. Does anyone have suggestions on how to do the equivalent streaming in react native? The way it works in Node is: var request = require('request'); var JSONStream = require('JSONStream'); var es = require('event-stream'); request(options) .pipe(JSONStream.parse('*')) .pipe(es.map(function(message) { handle(message) }));

Json Flutter - Error with Json post method in Flutter giving HTML error

i am trying to post to an api by flutter but it give me this error : I/flutter ( 5558): <!DOCTYPE html> I/flutter ( 5558): <html lang="en"> I/flutter ( 5558): <head> I/flutter ( 5558): <meta charset="utf-8"> I/flutter ( 5558): <title>Error</title> I/flutter ( 5558): </head> I/flutter ( 5558): <body> I/flutter ( 5558): <pre>Cannot POST /login</pre> I/flutter ( 5558): </body> I/flutter ( 5558): </html> I/flutter ( 5558): POST http://192.168.1.5:5000/login my code : void create() async { Dio dio = Dio(); var response = await http.post('http://192.168.1.5:5000/login',headers: { "Accept":"application/json", },body: { "username": "${usernameController.text}", "password": "${passwordController.text}" }); print(response.body); print(response.request); } anyone can help plz...