mirror of
https://github.com/desktop/desktop
synced 2024-09-20 16:41:37 +00:00
Camel case the response
This commit is contained in:
parent
5a40cdd2dc
commit
2585253e6b
22
app/npm-shrinkwrap.json
generated
22
app/npm-shrinkwrap.json
generated
|
@ -1,7 +1,12 @@
|
|||
{
|
||||
"name": "desktop",
|
||||
"version": "0.0.13",
|
||||
"version": "0.0.15",
|
||||
"dependencies": {
|
||||
"ansi-html": {
|
||||
"version": "0.0.6",
|
||||
"from": "ansi-html@0.0.6",
|
||||
"resolved": "https://registry.npmjs.org/ansi-html/-/ansi-html-0.0.6.tgz"
|
||||
},
|
||||
"ansi-regex": {
|
||||
"version": "2.0.0",
|
||||
"from": "ansi-regex@>=2.0.0 <3.0.0",
|
||||
|
@ -898,6 +903,21 @@
|
|||
"from": "timed-out@>=2.0.0 <3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/timed-out/-/timed-out-2.0.0.tgz"
|
||||
},
|
||||
"to-camel-case": {
|
||||
"version": "1.0.0",
|
||||
"from": "to-camel-case@latest",
|
||||
"resolved": "https://registry.npmjs.org/to-camel-case/-/to-camel-case-1.0.0.tgz"
|
||||
},
|
||||
"to-no-case": {
|
||||
"version": "1.0.2",
|
||||
"from": "to-no-case@>=1.0.0 <2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/to-no-case/-/to-no-case-1.0.2.tgz"
|
||||
},
|
||||
"to-space-case": {
|
||||
"version": "1.0.0",
|
||||
"from": "to-space-case@>=1.0.0 <2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/to-space-case/-/to-space-case-1.0.0.tgz"
|
||||
},
|
||||
"tough-cookie": {
|
||||
"version": "2.3.2",
|
||||
"from": "tough-cookie@>=2.3.0 <2.4.0",
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
"react-dom": "^15.3.2",
|
||||
"react-virtualized": "^8.0.11",
|
||||
"textarea-caret": "^3.0.1",
|
||||
"to-camel-case": "^1.0.0",
|
||||
"untildify": "^3.0.2",
|
||||
"username": "^2.2.2"
|
||||
},
|
||||
|
|
|
@ -9,6 +9,7 @@ import * as appProxy from '../ui/lib/app-proxy'
|
|||
const Octokat = require('octokat')
|
||||
const got = require('got')
|
||||
const username: () => Promise<string> = require('username')
|
||||
const camelCase: (str: string) => string = require('to-camel-case')
|
||||
|
||||
/** The response from `got` requests. */
|
||||
interface IHTTPResponse extends HTTP.IncomingMessage {
|
||||
|
@ -279,7 +280,7 @@ export async function fetchUser(endpoint: string, token: string): Promise<User>
|
|||
/** Get metadata from the server. */
|
||||
export async function fetchMetadata(endpoint: string): Promise<IServerMetadata> {
|
||||
const response = await request(endpoint, null, 'GET', 'meta', null)
|
||||
return response.body
|
||||
return toCamelCase(response.body)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -330,6 +331,17 @@ async function getNote(): Promise<string> {
|
|||
return `GitHub Desktop on ${localUsername}@${OS.hostname()}`
|
||||
}
|
||||
|
||||
/** Turn keys into camel case. */
|
||||
function toCamelCase(body: any): any {
|
||||
const result: any = {}
|
||||
for (const key in body) {
|
||||
const value = body[key]
|
||||
result[camelCase(key)] = value
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the URL for the HTML site. For example:
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue