Loading Markdown Files With the Angular HttpClient

Ole Ersoy
1 min readSep 19, 2019
Photo by Ksenia Makagonova on Unsplash

Scenario

We have a markdown file, 1.md , in the global assets folder and we want to load the content using the HttpClient .

Approach

Note that we set the responseType: 'text' option:

async ngOnInit() {
this.md = await this.http.get(`/assets/posts/1.md`,
{ responseType: 'text'}).toPromise();
}

Demo

--

--