micropython side code:
Code: Select all
response = {
'error': 'invalid request',
'status': 'retry'
}
Code: Select all
conn.send('HTTP/1.1 200 OK\n')
conn.send('Content-Type: application/json\n')
conn.send('Connection: close\n\n')
conn.sendall(ujson.dumps(response ))
Code: Select all
swriter.write(ujson.dumps(response ))
await swriter.drain()
Code: Select all
fetch( 'http://192.168.0.110' )
.then(response => response.json())
.then((responseJson) => {
const data1 = responseJson;
console.log('getting data from fetch', data1)
setData({ data1 });
onConnectionMessage(data1);
})
synchronous way I was able to retrieve the json output sent from esp32 to android app(react native), but the same code using asyncio i fail. asyncio client server code copied from peterhinch sir repository. What am I doing wrong?