mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
⚡ Minor improvements to Wordpress-Node
This commit is contained in:
parent
615a44726d
commit
7c54cf6ac2
|
@ -30,7 +30,7 @@ export async function wordpressApiRequest(this: IExecuteFunctions | IExecuteSing
|
||||||
method,
|
method,
|
||||||
qs,
|
qs,
|
||||||
body,
|
body,
|
||||||
uri: uri ||`${credentials!.url}/wp-json/wp/v2${resource}`,
|
uri: uri || `${credentials!.url}/wp-json/wp/v2${resource}`,
|
||||||
json: true
|
json: true
|
||||||
};
|
};
|
||||||
options = Object.assign({}, options, option);
|
options = Object.assign({}, options, option);
|
||||||
|
@ -41,7 +41,7 @@ export async function wordpressApiRequest(this: IExecuteFunctions | IExecuteSing
|
||||||
return await this.helpers.request!(options);
|
return await this.helpers.request!(options);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
let errorMessage = error.message;
|
let errorMessage = error.message;
|
||||||
if (error.response.body) {
|
if (error.response && error.response.body) {
|
||||||
errorMessage = error.response.body.message || error.response.body.Message || error.message;
|
errorMessage = error.response.body.message || error.response.body.Message || error.message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -238,7 +238,7 @@ export class Wordpress implements INodeType {
|
||||||
if (options.context) {
|
if (options.context) {
|
||||||
qs.context = options.context as string;
|
qs.context = options.context as string;
|
||||||
}
|
}
|
||||||
responseData = await wordpressApiRequest.call(this,'GET', `/posts/${postId}`, {}, qs);
|
responseData = await wordpressApiRequest.call(this, 'GET', `/posts/${postId}`, {}, qs);
|
||||||
}
|
}
|
||||||
//https://developer.wordpress.org/rest-api/reference/posts/#list-posts
|
//https://developer.wordpress.org/rest-api/reference/posts/#list-posts
|
||||||
if (operation === 'getAll') {
|
if (operation === 'getAll') {
|
||||||
|
@ -372,7 +372,7 @@ export class Wordpress implements INodeType {
|
||||||
if (options.context) {
|
if (options.context) {
|
||||||
qs.context = options.context as string;
|
qs.context = options.context as string;
|
||||||
}
|
}
|
||||||
responseData = await wordpressApiRequest.call(this,'GET', `/users/${userId}`, {}, qs);
|
responseData = await wordpressApiRequest.call(this, 'GET', `/users/${userId}`, {}, qs);
|
||||||
}
|
}
|
||||||
//https://developer.wordpress.org/rest-api/reference/users/#list-users
|
//https://developer.wordpress.org/rest-api/reference/users/#list-users
|
||||||
if (operation === 'getAll') {
|
if (operation === 'getAll') {
|
||||||
|
|
Loading…
Reference in a new issue