Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export function postCreateShare(ctx) {
- common.getSeesionInfo(ctx);
- const categories = {
- "Grain food": "https://cdn.pixabay.com/photo/2014/12/11/02/55/corn-syrup-563796__340.jpg",
- "Milk, cheese, eggs and alternatives": "https://image.shutterstock.com/image-photo/assorted-dairy-products-milk-yogurt-260nw-530162824.jpg",
- "Vegetables and legumes/beans": "https://www.eatforhealth.gov.au/sites/default/files/images/the_guidelines/101351132_vegetable_selection_web.jpg",
- "Fruits": "https://studyabroad.bg/wp-content/uploads/2019/10/fruits-tropicals-marguery-exclusive-villas-1400x933.jpg",
- "Lean meats and poultry, fish and alternatives": "https://i1.wp.com/www.daybyday.website/wp-content/uploads/2018/10/Nuts-And-Lean-Meat.jpeg?resize=618%2C412&ssl=1"
- }
- let { meal, prepMethod, description, foodImageURL, category } = ctx.params;
- if (meal && prepMethod && description && foodImageURL && category) {
- let recipe = {
- meal,
- prepMethod,
- description,
- foodImageURL,
- categoryImageURL: categories[category],
- likesCounter: 0,
- ingredients : ctx.params.ingredients.split(/[\s,]+/)
- };
- debugger;
- requster.post("appdata","recipes", recipe)
- .then(x=>{
- ctx.redirect('/');
- })
- .catch(console.error);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement