1

This should be very simple but I don't know why i can't get it right . i am building ionic app for a wordpress blog , where i want to get a single post id and display a single post , i can conform that the id is passed but when i enter in a http.get call , for some reasons it gets modified to

http://myURL/wp-json/wp/v2/posts/%7Bid%7D

This is my code

// Load a single post
    loadSinglePost(id:number): Observable<Post[]> {
    return this.http.get('http://bongosoka.com/wp-json/wp/v2/posts/${id}')
      .map(res => <Post[]>res.json());
    }

How do I get it to return the actual id ?

1 Answer 1

3

Use backticks for string interpolation

return this.http.get(`http://bongosoka.com/wp-json/wp/v2/posts/${id}`)

See also https://basarat.gitbooks.io/typescript/content/docs/template-strings.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.