File tree 1 file changed +16
-4
lines changed
1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -95,10 +95,22 @@ class TermsService {
95
95
* @param {Number|String } termId id of the term
96
96
* @return {Promise } promise of the request result
97
97
*/
98
- getTermDetails ( termId ) {
99
- // looks like server cache responses, to prevent it we add nocache param with always new value
100
- return this . private . api . get ( `/terms/${ termId } ` )
101
- . then ( res => ( res . ok ? res . json ( ) : Promise . reject ( res . json ( ) ) ) ) ;
98
+ async getTermDetails ( termId ) {
99
+ let termDetails = { } ;
100
+ let isLegacyTerm = false ;
101
+ if ( / ^ [ \d ] { 5 , 8 } $ / . test ( termId ) ) {
102
+ isLegacyTerm = true ;
103
+ termDetails = await this . private . api . get ( `/terms?legacyId=${ termId } ` )
104
+ . then ( res => ( res . ok ? res . json ( ) : Promise . reject ( res . json ( ) ) ) )
105
+ . then ( res => ( res . result ? res . result [ 0 ] : Promise . reject ( res . json ( ) ) ) ) ;
106
+ } else {
107
+ termDetails = await this . private . api . get ( `/terms/${ termId } ` )
108
+ . then ( res => ( res . ok ? res . json ( ) : Promise . reject ( res . json ( ) ) ) ) ;
109
+ }
110
+ return {
111
+ ...termDetails ,
112
+ isLegacyTerm,
113
+ } ;
102
114
}
103
115
104
116
/**
You can’t perform that action at this time.
0 commit comments