Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 71072

What is the proper ionic POST request to Shopify server

$
0
0

@ziaionic wrote:

hello @everyone
I’m sending a post request to store order in Shopify server it works perfectly from ``postman`

post body

{
  "order": 
        {
	      "currency": "AFN",
	      "customer":
	       {
	      	 "email": "foox@example.com",
	      	 "name": "Zia",
	      	 "phone": null
	       },
	      "financial_status": "pending",
	      "line_items": [
	        {
	          "price": 6000,
	          "quantity": 2,
	          "title": "Yellow Glass",
	          "variant_title": "Yellow Glass"
	        }
	      ],
	      "name": "Glass"
        }
}

but if I send this from ionic i get the following error in my console

this is the request in provider which HttpClient is injected into it.

  postOrder(order) {
    const headers: HttpHeaders = new HttpHeaders({
      Authorization: `Basic ${this.encoded}`,
    });
    return this.http.post("/api/admin/orders.json", order, { headers });
  }

and this is my .ts file which the provider injected into it

saveOrder() {
    let order = {
      "currency": "AFN",
      "customer":
      {
        "email": "fooxy@example.com",
        "name": "Zia",
        "phone": null
      },
      "financial_status": "pending",
      "line_items": [
        {
          "price": 6000,
          "quantity": 2,
          "title": "Yellow Glass",
          "variant_title": "Yellow Glass"
        }
      ],
      "name": "Glass"
    }

    console.log('Before sending ', order)

    this.provider.postOrder(order).subscribe(res => {
      console.log('Order sent > ', res)
    });
  }

but get request is working fine I can receive all the orders which are created in shopify

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 71072


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