<commit_before>'use strict'

const User = require('../models/user')
const rp = require('request-promise')

module.exports.addToWishlist = ({ session: { userId }, body: { bookId } }, res, err) => {
	User
		.findByIdAndUpdate( userId, { $push: { "wishlist": bookId } } )
		.then((data) => {
			console.log(data)
		})
}

module.exports.getWishlist = ({ session: { userId } }, res, err) => {
	User
		.findById(userId)
		.then((user) => {
			let promiseArray = []
			let books = user.wishlist.forEach(bookId => {
				let options = {
					uri: `https://www.googleapis.com/books/v1/volumes/${bookId}`,
					headers: {
        		'User-Agent': 'Request-Promise'<commit_msg>added remove from wishlist to wishlist controller in server<commit_after>'use strict'

const User = require('../models/user')
const rp = require('request-promise')

module.exports.addToWishlist = ({ session: { userId }, body: { bookId } }, res, err) => {
	User
		.findByIdAndUpdate( userId, { $push: { "wishlist": bookId } } )
		.then((data) => {
			res.json({data})
		})
}

module.exports.removeFromWishlist = ({ session: { userId }, body: { bookId } }, res, err) => {
	User
		.findByIdAndUpdate( userId, { $pull: { "wishlist": bookId } } )
		.then((data) => {
			res.json({data})
		})
}

module.exports.getWishlist = ({ session: { userId } }, res, err) => {
	User
		.findById(userId)
		.then((user) => {
			let promiseArray = []
			let books = user.wishlist.forEach(bookId => {
				let options = {
					uri: `https://www.googleapis.com/books/v1/volumes/${bookId}`,
					headers: {
        		'User-Agent': 'Request-Promise'
{'fraction_non_alphanumeric': 0.19080604534005038, 'fraction_numerical': 0.0012594458438287153, 'mean_word_length': 3.3653846153846154, 'pattern_counts': {'":': 3, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '338143', 'n_tokens_mistral': 611, 'n_tokens_neox': 571, 'n_words': 108}