Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix auto discovery #518

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Fix auto discovery #518

wants to merge 3 commits into from

Conversation

hajamie
Copy link

@hajamie hajamie commented May 8, 2024

There are a couple of open issues around this. I was trying to use auto discovery and it didn't work.
#504
#503

This seems to fix the issue. See https://stackoverflow.com/questions/546433/regular-expression-to-match-balanced-parentheses

I don't know how the testing or anything works. This is the first time I've made a contribution to a project, so apologies in advance!

hajamie added 3 commits May 8, 2024 17:55
Instead of creating a new regex which doesn't have match groups, just find the whole named group and use that instead.  
The original regex is also fine for checking if a part is a named group (as far as I'm aware).
@stevenalanstark
Copy link

stevenalanstark commented Jun 29, 2024

it worked for me. A much simpler regex with fewer wildcards.

I have issues with settings and themes, but I don't need these for my project

Also, I had to provide my own transport

My usage ( node ESM JS ):

import WPAPI from "wpapi";
import axios from "axios";

const API = new WPAPI( {
  endpoint: 'https://wordpress-acme.com/wp-json/',
  transport: axios
} );
const WP = await API.bootstrap();
const posts = await WP.posts();
const pages = await WP.pages();
const media = await WP.media();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants