Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49308

Get error 401 on images on WP Rest API

$
0
0

@ferdinandferdinandfe wrote:

Hello,

I’m using a basic authentication in my app to load articles of my wordpress which is locked with authentication.
I’ve used HttpHeaders but I don’t know why, every image returns a 401 error (unauthorized).

I thought it was a CORS issue until I tried on every browser, device and used a plugin to allow CORS on Chrome.

Here is the code that get the articles :

get(query: string = '') {

    let username = "test";
    let password = "test";
    const httpOptions = {
      headers: new HttpHeaders({
        'Authorization': 'Basic ' +
          btoa(username + ':' + password)
      })
    };

    return this.http.get(this.API_URL + query, httpOptions);
  }

and the code in home.html that fails to load
<img src="{{ item._embedded['wp:featuredmedia'][0].media_details.sizes.medium.source_url }}" />

It always shows this

Can anyone help ? Thank you

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49308

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>