Skip to content

Commit

Permalink
fix incorrect value for request.includeType
Browse files Browse the repository at this point in the history
  • Loading branch information
kketch committed Jul 11, 2021
1 parent 1ca92ff commit 26c53a1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/request/end.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

var map = require('../common/array/map')
var promise = require('../common/promise')
var assign = require('../common/assign')


/**
Expand Down Expand Up @@ -41,21 +42,20 @@ module.exports = function (context) {
return Promise.all(map(includeTypes, function (includeType) {
// This is useful for output hooks to know which type that the current
// record belongs to. It is temporary and gets deleted later.
request.includeType = includeType
var ctx = assign({}, context)
ctx.request = assign({}, request)
ctx.request.includeType = includeType

return Promise.all(map(include[includeType], function (record) {
return Promise.resolve(
typeof hooks[includeType][1] === 'function' ?
hooks[includeType][1](context, record) : record)
hooks[includeType][1](ctx, record) : record)
}))
}))

.then(function (types) {
var i, j, k, l

// Don't need this anymore.
delete request.includeType

// Assign results of output hooks on includes.
for (i = 0, j = types.length; i < j; i++)
for (k = 0, l = types[i].length; k < l; k++)
Expand Down

0 comments on commit 26c53a1

Please sign in to comment.