"No route was found matching the URL and request method"
Closed this issue · 4 comments
I get the following error after I run Ionic Serve and enter the page where I should receive the products from WooCommerce . This is the message I get in the debugger:
No route was found matching the URL and request method
Can you post the code you are using for this?
This is the page where i try to receive the products json from Woocommerce:
`import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams, AlertController } from 'ionic-angular';
import { WooApiService } from 'ng2woo';
@IonicPage()
@component({
selector: 'page-shop',
templateUrl: 'shop.html',
})
export class ShopPage {
WooCommerce: any;
constructor(public navCtrl: NavController, public navParams: NavParams,
private alertCtrl: AlertController, private woo: WooApiService) {
}
ionViewDidLoad() {
this.woo.fetchItems('products')
.then(products => console.log(products))
.catch(error => console.log(error));
}`
And this is my app.module.ts file:
`import { NgModule, ErrorHandler } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
import { MyApp } from './app.component';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { BrowserTab } from '@ionic-native/browser-tab';
import { HttpModule } from '@angular/http';
import { AngularFireDatabaseModule } from 'angularfire2/database';
import { AngularFireModule } from 'angularfire2';
import { Camera } from '@ionic-native/camera';
import { DatePicker } from '@ionic-native/date-picker';
import { EmailComposer } from '@ionic-native/email-composer';
import { WooApiModule, WooApiService } from 'ng2woo';
const WooCommerceConfig = {
url: 'https://colorvet.ro/wp-json/wc/v1/products',
consumerKey: 'xxxxxxxxxxxxxxxxxx', (i've replaced this with my consumerKey)
consumerSecret: 'xxxxxxxxxxxxxxx', (i've replaced this with my consumerSecret)
wpAPI: true,
version: 'wc/v1'
};
@NgModule({
declarations: [
MyApp,
],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp),
HttpModule,
WooApiModule.forRoot(WooCommerceConfig),
AngularFireDatabaseModule,
AngularFireModule.initializeApp(firebaseConfig), ],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
],
providers: [
StatusBar,
SplashScreen,
BrowserTab,
Camera,
WooApiService,
DatePicker,
EmailComposer,
{provide: ErrorHandler, useClass: IonicErrorHandler},
]
})
export class AppModule {}
`
In your app.module.ts
, use your root domain, and add queryStringAuth: true
:
const WooCommerceConfig = {
url: 'https://colorvet.ro', // use only your root URL
consumerKey: 'xxxxxxxxxxxxxxxxxx', (i've replaced this with my consumerKey)
consumerSecret: 'xxxxxxxxxxxxxxx', (i've replaced this with my consumerSecret)
wpAPI: true,
version: 'wc/v1',
queryStringAuth: true // add this
}
If you have problems with cordova ionic build --prod --release
change your import statement to this:
import { WooApiModule, WooApiService } from 'ng2woo/dist';
That was it, thank you!