evoleasing-account/actions/suggestsActions.js
2023-03-11 14:49:26 +03:00

42 lines
808 B
JavaScript

import axios from 'axios';
import { eachSeries } from 'async';
import * as actionTypes from '../constants/actionTypes';
import * as currentState from '../reducers/initialState';
if(process.browser)
{
FormData.prototype.appendObject = function(obj, namespace)
{
let keyName;
for (var key in obj)
{
if (obj.hasOwnProperty(key))
{
keyName = [namespace, '[', key, ']'].join('');
this.append(keyName, obj[key]);
}
}
};
}
export const getAddress = (text) =>
{
return new Promise((resolve, reject) =>
{
axios.post(`${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/suggests/address`, { text }, {
withCredentials: true,
})
.then((response) =>
{
resolve("");
})
.catch((error) =>
{
console.log("error");
console.error(error);
reject();
});
});
}