Get your http client module import it in your respective module. Also import it in your service, do the dependency injection thingy, create the method to be called on the service. Use the module like this
... Const url = 'u/r/l'; This.http.get(url, options); ... See the docs for more On Sat, Dec 28, 2019, 02:26 ahmed elbarbary <[email protected]> wrote: > i need to return json object from url > so my question How to write service and calling > this service on component ngoninit event > I actually need to return object from this url > so that > How to write service and calling on component ngoninit event > apiservice.ts > create service calling this link > http://192.168.4.233:9200/pcn/_search > > > and on component.ts > ngoninit > > > { > //How to call service and return data on variable > } > > > data returned as following > { > "_index": "partsdb", > "_type": "_doc", > "_id": "10", > "_version": 32, > "_seq_no": 115683922, > "_primary_term": 2, > "found": true, > "_source": { > "PID": 10, > "CID": 1005070, > "CN": "Texas Instruments Incorporated", > "PN": "THS6002CDWP", > "Eq": "Driver, Receiver and Transceiver Interface Transceiver 2 2 20HSOIC > Tube", > "FID": 4, > "FN": "THS6002", > "PaID": 5260, > "PaN": "20-HSOIC", > "PLID": 523842, > "PLN": "Driver, Receiver and Transceiver Interfaces", > "PLC": "Active", > "PIDT": 2007, > "ObY": 2024, > "NPI": false, > "FT": "THS6002 Dual Differential Line Driver/Receiver", > "DS": "277399925", > "FIDT": 1998, > "LCRev": 20777025, > "Masked_ID": 6012356, > "Compliance": [ > { > "RS": "Compliant", > "RET": "None", > "RV": "2015/863", > "RST": "Datasheet", > "CRS": "Compliant", > "HTS": "Compliant", > "RES": "Compliant", > "RESV": "JUL 2019 (201)", > "PNDR": 49416942, > "RHV": 963041, > "RECV": 273158534, > "HFR": 49416942 > } > ], > "PartScore": [ > { > "LCS": 46, > "MS": 15, > "RS": 11, > "SS": 5, > "CS": 0, > "S": 80, > "PRSID": 3, > "PAS": 5, > "FC": 0, > "CEL": 5, > "LTS": 3, > "FOD": "", > "IsMultiPackage": true, > "IsSolePackage": false, > "NumberOfAssembly": 1, > "NumberOfFab": 0, > "NumberOfFactory": 0, > "PackageUsage": 2, > "TechnologyStage": "" > } > ], > "Manufacturing": [ > { > "LFP": "NiPdAu", > "R": 10792132, > "MSL": "2", > "MSLR": 10792132, > "BM": "Cu", > "MRT": "260°C", > "MRTR": 10792132, > "MVT": "N/A", > "MVTR": 277399925, > "RST": "30", > "WST": "N/A", > "NOR": "3" > } > ], > "Package": [ > { > "LS": "Gull Wing", > "CPN": "20-HSOIC", > "NPN": "20-SOIC (0.295\", 7.50mm Width) Exposed Pad", > "PC": "20", > "MT": "Surface Mount", > "PPM": "1.27", > "JEDEC": "", > "D": "12.82 x 7.52 x 2.65", > "A": 96.406, > "T": 2.650, > "MXbdLn": "12.95", > "MxBdW": "7.59", > "MXbdH": "2.5", > "MXbdD": "N/R" > } > > -- > You received this message because you are subscribed to the Google Groups > "Angular and AngularJS discussion" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/angular/fec3b1df-2f06-40ba-a446-951e90defa5b%40googlegroups.com > <https://groups.google.com/d/msgid/angular/fec3b1df-2f06-40ba-a446-951e90defa5b%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/angular/CANmMz6QW9uEqYzb5Y1W_vsKXhXBvQeuNVktH-fmdGgF%2BoKRUEA%40mail.gmail.com.
