sms verification: pull out postToVerificationServer
This commit is contained in:
parent
9df0d33709
commit
b5560d27a0
@ -19,24 +19,10 @@ import qs from 'querystring';
|
|||||||
|
|
||||||
import TxHash from '../../../ui/TxHash';
|
import TxHash from '../../../ui/TxHash';
|
||||||
import waitForConfirmations from '../wait-for-confirmations';
|
import waitForConfirmations from '../wait-for-confirmations';
|
||||||
|
import postToVerificationServer from '../post-to-verification-server';
|
||||||
|
|
||||||
import styles from './sendRequest.css';
|
import styles from './sendRequest.css';
|
||||||
|
|
||||||
const postToVerificationServer = (query) => {
|
|
||||||
query = qs.stringify(query);
|
|
||||||
return fetch('https://sms-verification.parity.io/?' + query, {
|
|
||||||
method: 'POST', mode: 'cors', cache: 'no-store'
|
|
||||||
})
|
|
||||||
.then((res) => {
|
|
||||||
return res.json().then((data) => {
|
|
||||||
if (res.ok) {
|
|
||||||
return data.message;
|
|
||||||
}
|
|
||||||
throw new Error(data.message || 'unknown error');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
export default class SendRequest extends Component {
|
export default class SendRequest extends Component {
|
||||||
static contextTypes = {
|
static contextTypes = {
|
||||||
api: PropTypes.object.isRequired
|
api: PropTypes.object.isRequired
|
||||||
|
38
js/src/modals/SMSVerification/post-to-verification-server.js
Normal file
38
js/src/modals/SMSVerification/post-to-verification-server.js
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
// Copyright 2015, 2016 Ethcore (UK) Ltd.
|
||||||
|
// This file is part of Parity.
|
||||||
|
|
||||||
|
// Parity is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
|
||||||
|
// Parity is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import { stringify } from 'querystring';
|
||||||
|
|
||||||
|
const postToVerificationServer = (query) => {
|
||||||
|
query = stringify(query);
|
||||||
|
return fetch('https://sms-verification.parity.io/?' + query, {
|
||||||
|
method: 'POST', mode: 'cors', cache: 'no-store'
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
return res.json().then((data) => {
|
||||||
|
if (res.ok) {
|
||||||
|
return data.message;
|
||||||
|
}
|
||||||
|
throw new Error(data.message || 'unknown error');
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error('foooo', err.stack);
|
||||||
|
throw err
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export default postToVerificationServer;
|
Loading…
Reference in New Issue
Block a user