Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
getPrevAnswers.js
export const getPrevAnswers = async () => {
const options = getDropdownValues();
const [bedtimeValue, asleepValue] = [
random(0, options.length),
random(0, options.length)
]
.map(index => +options[index].value)
.sort((a, b) => a - b)
.reverse()
.map(value => `${value}`);
return new Promise(resolve =>
setTimeout(() =>
resolve({
json: () => ({
method: 'POST',
headers: {
'Content-Type': 'application/json;charset=utf-8'
},
body: { bedtimeValue, asleepValue },
})
}), 1000)
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment