The below code is failing on my request-promise, i already tried cleaning node_modules and installing the dependecies again
try {
const response = await request(reqOptions) // Error Highlighting `reqOptions`;
this.products = _.concat(this.products, response.products);
if(response.nextPage){
return this.getProductsCatalog(response.nextPage);
} else {
return Promise.resolve(this.products);
}
} catch(err) {
logger.error(err);
return Promise.reject(err);
}
error
No overload matches this call. Overload 1 of 3, '(uri: string, options?: RequestPromiseOptions, callback?: RequestCallback): RequestPromise', gave the following error. Argument of type '{ headers: { 'content-type': string; }; }' is not assignable to parameter of type 'string'. Overload 2 of 3, '(uri: string, callback?: RequestCallback): RequestPromise', gave the following error. Argument of type '{ headers: { 'content-type': string; }; }' is not assignable to parameter of type 'string'. Overload 3 of 3, '(options: (UriOptions & RequestPromiseOptions) | (UrlOptions & RequestPromiseOptions), callback?: RequestCallback): RequestPromise<...>', gave the following error. Argument of type '{ headers: { 'content-type': string; }; }' is not assignable to parameter of type '(UriOptions & RequestPromiseOptions) | (UrlOptions & RequestPromiseOptions)'. Type '{ headers: { 'content-type': string; }; }' is not assignable to type 'UrlOptions & RequestPromiseOptions'. Property 'url' is missing in type '{ headers: { 'content-type': string; };
Whole function
async getProductsCatalog(url: string): Promise<Product[]>{
if(url === null) {
this.products = [];;
return this.sendGetRequest('/v1/catalog/products',
{
pageSize: 40
}
)
.then((res) => JSON.parse(res))
.then((res) => {
const response: ProductCatalogResponse = res;
this.products = _.concat(this.products, response.products)
if(response.nextPage) {
return this.getProductsCatalog(response.nextPage);
} else {
return Promise.resolve(this.products);
}
});
} else {
let reqOptions = {
headers: {
'content-type': 'application/json'
}
};
this.visitRequest(reqOptions, 'GET', url, {pageSize: 40}, false)
try {
const response = await request(reqOptions);
this.products = _.concat(this.products, response.products);
if(response.nextPage){
return this.getProductsCatalog(response.nextPage);
} else {
return Promise.resolve(this.products);
}
} catch(err) {
logger.error(err);
return Promise.reject(err);
}
}
}