在angularjs中调用API。 [英] API calling in angularjs.

查看:81
本文介绍了在angularjs中调用API。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Assume that there are 3 APIs. Each API does exactly the same task(to give you weather details) but has different endpoints as follows:

API 1: Can only be used for India. Has methods named requestWeather(), requestWeatherDataForWeek()

API 2: Can only be used for the USA. Has methods named sendRequest(), weatherDataForWeek()

API 3: Can only be used for the UK. Has methods named getWeather(), getWeatherDataForWeek().

Select the country using the drop-down.

a. Select the API according to the country. API selection is programmatic, which will be decided according to the country selected by the user.

b. Write your code such that, any API can be used without disturbing the business logic.

c. There must be a limit on the number of requests that can be sent. Throw an error if no. of requests exceed the limit.

d. It does not require HTTP calls or APIs. Just create a wrapper for API with the specified method and return some dummy values.

What I have tried:

I have tried doing it using HTTP calls or APIs. How to create a wrapper??

推荐答案

如何使用Angular 2的HTTP客户端与Gistia交谈后端服务 [ ^ ]


这篇关于在angularjs中调用API。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆