Skip to content

Commit

Permalink
fix for msg.payload issue (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
bikerpatch authored Jul 19, 2022
1 parent 33cff75 commit ea4890f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

- Better error catching of bad parameter values
- Catch errors to do with API rate limit
- [**Stock Time Series Daily node**] - **Bug Fix** Handle non-initialised `msg.payload` in response
- [**Stock Time Series Intraday node**] - **Bug Fix** Handle non-initialised `msg.payload` in response

## [0.2.0] - 18/07/2022

Expand Down
8 changes: 5 additions & 3 deletions src/stock-daily.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ module.exports = (RED) => {

const result = api.util.polish(await api.data.daily(symbol, outputSize, "json"))

msg.payload.series = mapSeriesObj(result.data) // backward compat
msg.payload.seriesArray = mapSeriesArray(result.data) // new array
msg.payload.data = mapData(result.meta) // backward compat
msg.payload = {
series: apiUtil.mapSeriesObj(result.data), // backward compat
seriesArray: apiUtil.mapSeriesArray(result.data), // new array
data: apiUtil.mapData(result.meta) // backward compat
}

Send(msg)
Done()
Expand Down
13 changes: 5 additions & 8 deletions src/stock-intraday.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,11 @@ module.exports = (RED) => {

const timeSeriesKey = `Time Series (${intervalStr}min)`

result.data = mapData(result.meta) // backward compat
result.series = mapSeriesObj(result[timeSeriesKey]) // backward compat
result.seriesArray = mapSeriesArray(result[timeSeriesKey]) // new array

delete(result.meta)
delete(result[timeSeriesKey])

msg.payload = result
msg.payload = {
data: apiUtil.mapData(result.meta), // backward compat
series: apiUtil.mapSeriesObj(result[timeSeriesKey]), // backward compat
seriesArray: apiUtil.mapSeriesArray(result[timeSeriesKey]), // new array
}

Send(msg)
Done()
Expand Down

0 comments on commit ea4890f

Please sign in to comment.