@@ -1064,7 +1064,7 @@ Adapter.extend({
1064
1064
*
1065
1065
* // GET /reports/schools/:school_id/teachers
1066
1066
* addAction('getTeacherReports', {
1067
- * basePath : 'reports/schools',
1067
+ * endppoint : 'reports/schools',
1068
1068
* pathname: 'teachers',
1069
1069
* method: 'GET'
1070
1070
* })(store.getMapper('school'))
@@ -1098,42 +1098,36 @@ export function addAction (name, opts) {
1098
1098
opts . response = opts . response || function ( response ) { return response }
1099
1099
opts . responseError = opts . responseError || function ( err ) { return utils . reject ( err ) }
1100
1100
mapper [ name ] = function ( id , _opts ) {
1101
- if ( utils . isObject ( id ) ) {
1102
- _opts = id
1103
- }
1104
1101
_opts = _opts || { }
1105
- let adapter = this . getAdapter ( opts . adapter || this . defaultAdapter || 'http' )
1106
- let config = { }
1107
- utils . fillIn ( config , opts )
1108
- if ( ! _opts . hasOwnProperty ( 'endpoint' ) && config . endpoint ) {
1109
- _opts . endpoint = config . endpoint
1110
- }
1102
+ utils . fillIn ( _opts , opts )
1103
+ let adapter = this . getAdapter ( _opts . adapter || this . defaultAdapter || 'http' )
1104
+ const config = { }
1105
+ config . mapper = this . name
1106
+ utils . deepMixIn ( config , _opts )
1107
+ config . method = config . method || 'GET'
1111
1108
if ( typeof _opts . getEndpoint === 'function' ) {
1112
1109
config . url = _opts . getEndpoint ( this , _opts )
1113
1110
} else {
1114
1111
let args = [
1115
1112
_opts . basePath || this . basePath || adapter . basePath ,
1116
- adapter . getEndpoint ( this , utils . isSorN ( id ) ? id : null , _opts )
1113
+ adapter . getEndpoint ( this , id , _opts )
1117
1114
]
1118
1115
if ( utils . isSorN ( id ) ) {
1119
1116
args . push ( id )
1120
1117
}
1121
1118
args . push ( opts . pathname || name )
1122
1119
config . url = makePath . apply ( null , args )
1123
1120
}
1124
- config . method = config . method || 'GET'
1125
- config . mapper = this . name
1126
- utils . deepMixIn ( config , _opts )
1127
1121
return utils . resolve ( config )
1128
- . then ( _opts . request || opts . request )
1122
+ . then ( _opts . request )
1129
1123
. then ( ( config ) => adapter . HTTP ( config ) )
1130
1124
. then ( ( data ) => {
1131
1125
if ( data && data . config ) {
1132
1126
data . config . mapper = this . name
1133
1127
}
1134
1128
return data
1135
1129
} )
1136
- . then ( _opts . response || opts . response , _opts . responseError || opts . responseError )
1130
+ . then ( _opts . response , _opts . responseError )
1137
1131
}
1138
1132
return mapper
1139
1133
}
0 commit comments