tdurieux / leboncoin-api

DEPRECATED
https://www.npmjs.com/package/leboncoin-api
169 stars 54 forks source link

addSearchExtra failed with key 'real_estate_type' #66

Closed jdenoeud closed 4 years ago

jdenoeud commented 4 years ago

Thank you for your work on this project ! That's really great !

I started to work with, using the README.md example file. I modified it a little bit to create a query for "ventes_immobilieres" category. Here is the way it set my request:

var search = new leboncoin.Search() .setPage(1) .setQuery("") .setFilter(leboncoin.FILTERS.PARTICULIER) .setCategory("ventes_immobilieres") .setRegion("provence_alpes_cote_d_azur") .setDepartment("vaucluse") .setArea({"lat": 43.82393, "lng": 5.30872, "radius": 10000}) .addSearchExtra("price", {min: 0, max: 100000}) .addSearchExtra("immo_sell_type", "old") .addSearchExtra("real_estate_type", "1")

I am facing the following issue: TypeError: search.map is not a function at Search.setRegion.Search.setDepartment.Search.setCategory.search.map (/home/justine/Documents/workspace/node_modules/leboncoin-api/lib/search.js:215:21) at /home/justine/Documents/workspace/node_modules/leboncoin-api/lib/search.js:260:30 at /home/justine/Documents/workspace/node_modules/lodash/lodash.js:4925:15 at baseForOwn (/home/justine/Documents/workspace/node_modules/lodash/lodash.js:2990:24) at /home/justine/Documents/workspace/node_modules/lodash/lodash.js:4894:18 at Function.forEach (/home/justine/Documents/workspace/node_modules/lodash/lodash.js:9368:14) at LodashWrapper.object.(anonymous function) [as forEach] (/home/justine/Documents/workspace/node_modules/lodash/lodash.js:15758:25) at Search.setRegion.Search.setDepartment.Search.setCategory._.forEach (/home/justine/Documents/workspace/node_modules/leboncoin-api/lib/search.js:252:21) at Search.setRegion.Search.setDepartment.Search.setCategory.Search.getBodyParams (/home/justine/Documents/workspace/node_modules/leboncoin-api/lib/search.js:307:22) at Search.setRegion.Search.setDepartment.Search.setCategory.Search.run (/home/justine/Documents/workspace/node_modules/leboncoin-api/lib/search.js:362:51)

I noticed that "immo_sell_type" is not among the constant in /const/subcategories.json, is it normal ? I based my query from the html source code: "query":{"category":"9","immo_sell_type":"old","locations":"Bonnieux_84480__43.82393_5.30872_6536_10000","price":"min-200000","real_estate_type":"1"}

I think the issue comes from "real_estate_type" key but I am not sure. Thanks for your help !

tdurieux commented 4 years ago

I pushed an update of the lib that should fix this problem.