Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect value for request.includeType #322

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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