I'm trying to send data to the event hub from the azure function written on node js. But I'm getting the following error when I send the array of objects without.
No events found for 'NSEStockInput'.
Start time: Monday, September 23, 2019, 6:56:00 PM
End time: Monday, September 23, 2019, 6:59:00 PM
Last time arrival: Monday, September 23, 2019, 6:59:08 PM
Diagnostics: Source '<unknown_location>' had 1 occurrences of kind 'InputDeserializerError.InvalidData' between processing times '2019-09-23T13:29:10.4592579Z' and '2019-09-23T13:29:10.4592579Z'. Json input stream should either be an array of objects or line separated objects. Found token type: Null
But when I'm JSON.stringify the data I'm getting error as
Exception: Error: data is required and it must be of type object.
Here the code that I have written
module.exports = async function (context, myTimer) {
const { EventHubClient, EventData, EventPosition, OnMessage, OnError, MessagingError } = require("@azure/event-hubs");
const connectionString = connectionString
var axios = require('axios')
context.log('ssss')
const client = EventHubClient.createFromConnectionString(connectionString);
context.log('sssaaa')
var response = await axios.get('https://nseindia.com/live_market/dynaContent/live_watch/stock_watch/nifty500StockWatch.json')
await client.send(JSON.stringify(response['data']['data']))
context.log('message sent')
};
How to resolve this issue