0
I set up a website to study a store Woocommerce, activated the api and generated the keys.
At the root of the added site on . htaccess, is that in the correct location?:
# Permite acesso ao pacote Font Awesome
<FilesMatch ".(ttf|otf|woff)$">
Header set Access-Control-Allow-Origin "*"
</FilesMatch>
Here is the full code for testing:
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import * as WC from 'woocommerce-api';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
WooCommerce: any;
products:any[];
constructor(public navCtrl: NavController) {
this.WooCommerce = WC({
url:"http://wooionic.comajudacoletiva.com.br/",
consumerKey:"ck_899d1c4011cab2bde1f04cd52704c248f155ecdc",
consumerSecret:"cs_cc90feaf8467c0a53679be89f137557cdc7acbe5"
});
this.WooCommerce.getAsync("products").then( (data) => {
console.log(JSON.parse(data.body));
// this.products = JSON.parse(data.body).products;
}, (err) => {
console.log(err)
})
}
}
I’ve done it and it didn’t work
– Harry
@itasouza I looked at the reply headers on your site http://wooionic.comajudacolectivo.com.br/ and is not returning the Access-Control-Allow-Origin, the . htaccess is at the root of wooionic.comajudacoletiva.com.br site ?
– Guilherme Nascimento
yes, it’s at the root
– Harry
@itasouza checks the name name if this
.htaccess
, with two letters c and two letters s, then check the contents in FTP, maybe you have not updated correctly. If you don’t let me know I’ll run some tests ;)– Guilherme Nascimento
detail, when I said site root I meant within the subdomain "wooionic.comajudacolectivo.com.br" and not within httpdocs
– Harry
I have now added in httpdocs and out of it
– Harry
Your server is IIS right? @itasouza I had thought it was Apache
– Guilherme Nascimento
Let’s go continue this discussion in chat.
– Harry
I made the adjustment you gave me, already added the web.config in the site root and also in the root of the subdomain, removing the ".htaccess" because the server and Windows. I have not yet tested to know if you are releasing the remote access, anyway thank you for the help.
– Harry