mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-27 01:25:52 -05:00
check street number range for address
rather than exact address, so that we can more flexibly allow outdate post office data
This commit is contained in:
parent
00920e7da6
commit
4d9fe86f40
2 changed files with 13 additions and 8 deletions
|
@ -1,4 +1,5 @@
|
|||
var defaults = require('lodash.defaults');
|
||||
var defaultsDeep = require('lodash.defaultsdeep');
|
||||
var xhr = require('xhr');
|
||||
|
||||
var jar = require('./jar');
|
||||
|
@ -15,17 +16,15 @@ var urlParams = require('./url-params');
|
|||
*/
|
||||
|
||||
module.exports = function (opts, callback) {
|
||||
defaults(opts, {
|
||||
defaultsDeep(opts, {
|
||||
host: process.env.API_HOST,
|
||||
headers: {},
|
||||
headers: {
|
||||
'X-Requested-With': 'XMLHttpRequest'
|
||||
},
|
||||
responseType: 'json',
|
||||
useCsrf: false
|
||||
});
|
||||
|
||||
defaults(opts.headers, {
|
||||
'X-Requested-With': 'XMLHttpRequest'
|
||||
});
|
||||
|
||||
opts.uri = opts.host + opts.uri;
|
||||
|
||||
if (opts.params) {
|
||||
|
@ -43,7 +42,9 @@ module.exports = function (opts, callback) {
|
|||
// For IE < 10, we must use XDR for cross-domain requests. XDR does not support
|
||||
// custom headers.
|
||||
defaults(opts, {useXDR: true});
|
||||
delete opts.headers;
|
||||
if (opts.useXDR) {
|
||||
delete opts.headers;
|
||||
}
|
||||
if (opts.authentication) {
|
||||
var authenticationParams = ['x-token=' + opts.authentication];
|
||||
var parts = opts.uri.split('?');
|
||||
|
|
|
@ -8,7 +8,11 @@ module.exports = function smartyStreetApi (params, callback) {
|
|||
api({
|
||||
host: 'https://api.smartystreets.com',
|
||||
uri: '/street-address',
|
||||
params: params
|
||||
headers: {
|
||||
'X-Standardize-Only': true
|
||||
},
|
||||
params: params,
|
||||
useXDR: false
|
||||
}, function (err, body, res) {
|
||||
if (err) return callback(err);
|
||||
if (res.statusCode !== 200) {
|
||||
|
|
Loading…
Reference in a new issue