Call api in ionic


#1

Curl

curl -X POST  \https://api.pix.com/v3/latex
    -H 'app_id: trial' \
    -H 'app_key: 34f1a4cea0eaca8540c95908b4dc84ab' \
    -H 'Content-Type: application/json' \
    --data '{ "url": "data:image/jpeg;base64,'$(base64 -i limit.jpg)'" }'

Python

#!/usr/bin/env python
import sys
import base64
import requests
import json

# put desired file path here
file_path = 'limit.jpg'
image_uri = "data:image/jpg;base64," + base64.b64encode(open(file_path, "rb").read())
r = requests.post("https://api.pix.com/v3/latex",
    data=json.dumps({'url': image_uri}),
    headers={"app_id": "trial", "app_key": "34f1a4cea0eaca8540c95908b4dc84ab",
            "Content-type": "application/json"})
print json.dumps(json.loads(r.text), indent=4, sort_keys=True)

How to make it work in Ionic?


#2

https://angular.io/api/http/Http


#4

RIght now you just take the array ob image names (strings), and put it into a string you say to be base64.
You will actually have to open and read the image, convert it to base64 and then put this into the data object.


#7

Could you share it with us?


#8

I found this one