Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var result = await fetch(url, {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json"
},
body: JSON.stringify(body),
credentials: CREDENTIALS
});
const data = await result.json();
if (data.resCode !== 200) {
if (data.resCode === 401) {
emitter.emit("USER_INVALID");
}
toast.error(data.message, {
position: toast.POSITION.TOP_RIGHT
});
throw new Error(data.message);
}
return {
data
};
} catch (e) {
return {
message: e.message,
};
}
};
async function run() {
try {
const { LiveSplit } = await import("./ui/LiveSplit");
ReactDOM.render(
<div>
</div>,
document.getElementById("base"),
);
} catch (_) {
alert(`Couldn't load LiveSplit One. \
You may be using a browser that doesn't support WebAssembly. \
Alternatively, you may be using an Adblocker like uBlock Origin. \
Those are known to block WebAssembly.`);
}
}
notifySuccess = (message, duration = 1500) => {
toast.success(message, {
position: toast.POSITION.BOTTOM_RIGHT,
className: 'toast-default',
progressClassName: 'toast-progress-default',
autoClose: duration,
});
};
notifyError = (message, duration = 1500) => {
.catch(() => {
const errorMsg = 'Couldn\'t delete record.'
toast.error(errorMsg, {
position: toast.POSITION.TOP_RIGHT
});
this.setState({
error: {
message: errorMsg
}
})
});
}
.then(() => {
this.loggingIn = false;
toast.success("Logged in", {
position: toast.POSITION.BOTTOM_RIGHT,
autoClose: 1500,
});
})
.catch(err => {
handleSubmit = event => {
event.preventDefault();
const errors = this.validate();
this.setState({ errors: errors || {} });
if (errors) return;
if (!errors) {
const { title, url, tag, pinned } = this.state;
const createdAt = Math.floor(Date.now() / 1000);
const userId = this.props.auth.uid;
const bookmark = { title, url, tag, pinned, createdAt, userId };
this.props.createBookmark(bookmark);
this.setState({ title: "", url: "", tag: "" });
toast.success("Bookmark added!", {
position: toast.POSITION.BOTTOM_CENTER
});
}
};
render() {
return (
<div>
</div>
);
}
.then((response) => {
if (response.ok) {
toast('Project added successfully !', {
position: toast.POSITION.TOP_CENTER,
autoClose: 3000,
hideProgressBar: true,
closeOnClick: true,
});
} else {
toast.error('Error while saving the project! ', {
position: toast.POSITION.TOP_CENTER,
autoClose: 3000,
hideProgressBar: true,
closeOnClick: true,
});
}
})
.catch((error) => {
validateContactNumber = number => {
if (number.length < 10) {
toast.error("Please enter a valid 10 digit phone number", {
position: toast.POSITION.BOTTOM_RIGHT
})
this.setState({ contactNumber: "" })
return false
}
if (isNaN(Number(number))) {
toast.error("Please enter number without spaces or hyphens", {
position: toast.POSITION.BOTTOM_RIGHT
})
this.setState({ contactNumber: "" })
return false
}
return true
}
componentDidMount() {
toast("Default Notification !");
toast.success("Success Notification !", {
position: toast.POSITION.TOP_CENTER
});
toast.error("Error Notification !", {
position: toast.POSITION.TOP_LEFT
});
toast.warn("Warning Notification !", {
position: toast.POSITION.BOTTOM_LEFT
});
toast.info("Info Notification !", {
position: toast.POSITION.BOTTOM_CENTER
});
toast("Custom Style Notification !", {
position: toast.POSITION.BOTTOM_RIGHT,
className: 'dark-toast',
progressClassName: 'transparent-progress'
});
}