Answer the question
In order to leave comments, you need to log in
How to send curl via Angular?
I'm trying to send curl like this:
curl -X POST https://secure.payu.com/api/v2_1/orders \
-H "Content-Type: application/json" \
-H "Authorization: Bearer 3e5cac39-7e38-4139-8fd6-30adc06a61bd" \
-d '{
"notifyUrl": "https://your.eshop.com/notify",
"customerIp": "127.0.0.1",
"merchantPosId": "145227",
"description": "RTV market",
"currencyCode": "PLN",
"totalAmount": "21000",
"buyer": {
"email": "[email protected]",
"phone": "654111654",
"firstName": "John",
"lastName": "Doe",
"language": "pl"
},
"products": [
{
"name": "Wireless Mouse for Laptop",
"unitPrice": "15000",
"quantity": "1"
},
{
"name": "HDMI cable",
"unitPrice": "6000",
"quantity": "1"
}
]
}'
const body = {
"notifyUrl": "https://your.eshop.com/notify",
"customerIp": "127.0.0.1",
"merchantPosId": "145227",
"description": "RTV market",
"currencyCode": "PLN",
"totalAmount": "21000",
"buyer": {
"email": "[email protected]",
"phone": "654111654",
"firstName": "John",
"lastName": "Doe",
"language": "pl"
},
"products": [
{
"name": "Wireless Mouse for Laptop",
"unitPrice": "15000",
"quantity": "1"
},
{
"name": "HDMI cable",
"unitPrice": "6000",
"quantity": "1"
}
]
}
this.http
.post<any>('https://secure.snd.payu.com/api/v2_1/orders', body, { headers: headers })
.subscribe(res => {
console.log(res);
});
Access to XMLHttpRequest at ' https://secure.snd.payu.com/api/v2_1/orders ' from origin ' localhost:4200 ' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Answer the question
In order to leave comments, you need to log in
the default browser checks whether the current site is allowed to make requests to a specific server (CORS policy).
to get around this, you must either add CORS support for the server or disable CORS in the browser
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question