Advertisement
dimitrix85

Untitled

Dec 3rd, 2019
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. export function postCreateShare(ctx) {
  2.    
  3.     common.getSeesionInfo(ctx);
  4.     const categories = {
  5.         "Grain food": "https://cdn.pixabay.com/photo/2014/12/11/02/55/corn-syrup-563796__340.jpg",
  6.         "Milk, cheese, eggs and alternatives": "https://image.shutterstock.com/image-photo/assorted-dairy-products-milk-yogurt-260nw-530162824.jpg",
  7.         "Vegetables and legumes/beans": "https://www.eatforhealth.gov.au/sites/default/files/images/the_guidelines/101351132_vegetable_selection_web.jpg",
  8.         "Fruits": "https://studyabroad.bg/wp-content/uploads/2019/10/fruits-tropicals-marguery-exclusive-villas-1400x933.jpg",
  9.         "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"
  10.     }
  11.  
  12.     let { meal, prepMethod, description, foodImageURL, category } = ctx.params;
  13.  
  14.     if (meal && prepMethod && description && foodImageURL && category) {
  15.     let recipe = {
  16.         meal,
  17.         prepMethod,
  18.         description,
  19.         foodImageURL,
  20.         categoryImageURL: categories[category],
  21.         likesCounter: 0,
  22.         ingredients : ctx.params.ingredients.split(/[\s,]+/)
  23.     };
  24.     debugger;
  25.     requster.post("appdata","recipes", recipe)
  26.     .then(x=>{
  27.         ctx.redirect('/');
  28.     })
  29.     .catch(console.error);
  30.     }
  31.    
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement