Skip to content

Commit

Permalink
Make fromApi lazy and skip parser creation
Browse files Browse the repository at this point in the history
  • Loading branch information
dmsnell committed May 6, 2018
1 parent cf06bcb commit 8defd8f
Showing 1 changed file with 2 additions and 24 deletions.
26 changes: 2 additions & 24 deletions client/state/data-layer/http-data/getters.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
/**
* Internal dependencies
*/
import makeJsonSchemaParser from 'lib/make-json-schema-parser';
import { http as rawHttp } from 'state/http/actions';
import { requestHttpData } from 'state/data-layer/http-data/common';
import { requestHttpData } from 'state/data-layer/http-data';

export const requestGeoLocation = () =>
requestHttpData(
Expand All @@ -13,26 +12,5 @@ export const requestGeoLocation = () =>
method: 'GET',
url: 'https://public-api.wordpress.com/geo/',
} ),
{
fromApi: makeJsonSchemaParser(
{
type: 'object',
properties: {
body: {
type: [ 'object', 'null' ],
properties: {
latitude: { type: 'string' },
longitude: { type: 'string' },
country_short: { type: 'string' },
country_long: { type: 'string' },
region: { type: 'string' },
city: { type: 'string' },
},
},
},
},
// we only use the short code currently
( { body: { country_short } } ) => [ [ 'geo', country_short ] ]
),
}
{ fromApi: ( { body: { country_short } } ) => [ [ 'geo', parseInt( country_short, 10 ) ] ] }
);

0 comments on commit 8defd8f

Please sign in to comment.