mirror of
				https://github.com/elyby/accounts-frontend.git
				synced 2025-05-31 14:11:58 +05:30 
			
		
		
		
	правильная true/false сериализация для request
This commit is contained in:
		| @@ -1,8 +1,22 @@ | |||||||
|  | function convertQueryValue(value) { | ||||||
|  |     if (typeof value === 'undefined') { | ||||||
|  |         return ''; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     if (value === true) { | ||||||
|  |         return 1; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     if (value === false) { | ||||||
|  |         return 0; | ||||||
|  |     } | ||||||
|  | } | ||||||
|  |  | ||||||
| function buildQuery(data) { | function buildQuery(data) { | ||||||
|     return Object.keys(data) |     return Object.keys(data) | ||||||
|         .map( |         .map( | ||||||
|             (keyName) => |             (keyName) => | ||||||
|                 [keyName, typeof data[keyName] === 'undefined' ? '' : data[keyName]] |                 [keyName, convertQueryValue(data[keyName])] | ||||||
|                     .map(encodeURIComponent) |                     .map(encodeURIComponent) | ||||||
|                     .join('=') |                     .join('=') | ||||||
|         ) |         ) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user