Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.setState({ results: null })
return
}
try {
this.setState({ inProgress: true, results: null })
const queryString = qs.stringify({
query,
page: page && page > 0 ? page + 1 : undefined,
sloppy: sloppy ? 1 : undefined
})
// If we're typing fast, don't add incomplete queries to browser history.
if (this.inFlightRequest) {
Router.replace('/?' + queryString)
} else {
Router.push('/?' + queryString)
}
if (this.inFlightRequest) this.inFlightRequest.abort()
const req = this.inFlightRequest = request.get(getOrigin() + '/search').query(queryString).withCredentials()
const response = await req
const obj = response.body
if (obj.error) {
// Elasticsearch will complain about broken queries, like '"foo' (missing a double quote)
if (/QueryParsingException/.test(obj.error)) {
obj.error = <span>
That search query looks incomplete. Please see the {' '}
<a href="https://www.elastic.co/guide/en/elasticsearch/reference/1.7/query-dsl-query-string-query.html#query-string-syntax">Elasticsearch 1.7 query string documentation</a>.
</span>
export const redirect = (context, target) => {
if (context.res) {
// server
// 303: "See other"
context.res.writeHead(303, { Location: target });
context.res.end();
} else {
// In the browser, we just pretend like this never even happened ;)
Router.replace(target);
}
};
async handleDelete (act) {
if (!act) return
// Actual data request
await this.props.dispatch(reduxApi.actions.activities.delete({ id: act._id }))
// TODO error handling - how can this fail?
message.success('Deleted. ')
Router.replace(`/acts`)
}
export default (context, target, code = 303) => {
if (context.res || !process.browser) {
// server
// 303: "See other"
context.res.writeHead(code, {Location: target});
context.res.end();
} else {
// In the browser, we just pretend like this never even happened ;)
Router.replace(target);
}
};
async componentDidMount() {
const { stores } = this.props
stores.authStore.syncToken()
if (stores.authStore.loggedIn) {
Router.replace(this.props.router!.query.redirect_url)
return
}
}
componentWillMount() {
if (this.props.err) {
Router.replace({ pathname: '/3-me/2-login', query: { href: '/1-loan/3-goLoan', as: '/loan/go' } }, '/login')
}
}
componentDidMount() {
componentDidMount () {
const { to, as, options, replace } = this.props
if (to) {
if (replace) {
Router.replace(to, as, options)
} else {
Router.push(to, as, options)
}
}
}
.then(() => Router.replace("/dashboard"))
.catch((error: GraphQLError) => {
clearQueryParams = () => {
const newUrl = this.props.url;
this.props.profileQuestions.forEach(q => {
newUrl.query[q.variable_name] = "";
});
newUrl.query["selectedNeeds"] = {};
Router.replace(mutateUrl(newUrl, "", ""));
};