Last active
May 19, 2019 11:12
-
-
Save PyroGenesis/4a34c8ecc7fb3bc7cc2779ee93c317f1 to your computer and use it in GitHub Desktop.
Angular request with Body (FormData and JSON)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
POST_with_FormData(fileblob): Observable<any> { | |
const URL = 'YOUR_URL_HERE'; | |
const data = new FormData(); | |
data.append('product_Id', '123'); | |
data.append('file', fileblob); | |
return this.httpClient.post<any>(URL, data); // returns an Observable | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
POST_with_JSON(): Observable<any> { | |
const URL = 'YOUR_URL_HERE'; | |
const data = { | |
"testobj": { | |
"testnum": 5, | |
"teststr": "hello" | |
}, | |
"testarr": [1, 2, 3] | |
} | |
return this.httpClient.post<any>(URL, JSON.stringify(data)); // returns an Observable | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment