2-2 JavaScript API Reference

Calling Web Services

playground.restaurant์—์„œ ์‚ฌ์šฉ๋œ REST ๊ธฐ๋ฐ˜์˜ ์›น์„œ๋น„์Šค๋ฅผ ์œ„ํ•œ APIํ˜ธ์ถœ์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. ์„ค๋ช…์„ ๋”ฐ๋ผ๊ฐ€๋ฉด์„œ API๋ฅผ ํ˜ธ์ถœํ•˜์—ฌ data ๋ณ€์ˆ˜์— ๊ฐ’์„ ์ €์žฅํ•˜๋Š” ์ฝ”๋“œ๋ฅผ ์ฑ„์›Œ๋ณด์„ธ์š”.

url๊ณผ jsonQuery, options ๋ณ€์ˆ˜์—๋Š” ํ•„์š”ํ•œ ์ •๋ณด๋“ค์ด ์ €์žฅ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ ์ค‘ jsonQuery ๋ณ€์ˆ˜๋Š” options์— ๋งค์นญ๋˜์–ด ์‚ฌ์šฉ๋˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ๋‘ ๊ฐ€์ง€ ๋ณ€์ˆ˜์ธ url๊ณผ options parameter๋กœ ์‚ฌ์šฉํ•˜๋Š” getUrl ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•˜์—ฌ data ๋ณ€์ˆ˜์— ๋ง›์ง‘ ์ •๋ณด๋ฅผ ์ €์žฅํ•ด๋ณด์„ธ์š”.

์ง€๊ธˆ๋ถ€ํ„ฐ Developer Center์˜ ์˜ˆ์ œ๋ฅผ ํ†ตํ•ด์„œ ์ •๋‹ต์„ ์ฐพ์•„๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค!

REST

REST ๊ธฐ๋ฐ˜์˜ ์›น์„œ๋น„์Šค๋ฅผ ์ด์šฉํ•˜๋Š” APIํ˜ธ์ถœ ๋ฐฉ๋ฒ•์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

http.getUrl(url, options)
http.postUrl(url, params, options)
http.putUrl(url, params, options)
http.deleteUrl(url, params, options)

์—ฌ๊ธฐ์—์„œ url์€ ์ œ๊ณตํ•˜๋Š” ์›น ์„œ๋ฒ„์— ๋Œ€ํ•œ ์ •๋ณด์ž…๋‹ˆ๋‹ค.

options ๋Š” JSON๊ธฐ๋ฐ˜์˜ ๊ฐ์ฒด์ด๊ณ  ๋‹ค์Œ๊ณผ ๊ฐ™์€ parameter๋“ค์„ ๊ฐ€์ง€๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

  • format: This specifies how the response will be processed. It may be one of 'text', 'json', 'xmljs', or 'csv'.

  • query: An object with attribute/value pairs to pass as arguments to the REST service.

  • basicAuth: HTTP Basic Authentication. The value must be an object with "username" and "password".

  • cacheTime: Cache time in milliseconds. By default, all GET requests are cached in memory. An alternate cache time may be provided.

  • headers: An object with key/value pairs for additional HTTP headers. This may be used for custom Content-Type settings (such as XML).

  • passAsJson (POST call only): If set to true, passes the request parameters in the body in JSON format and sets the content type appropriately.

  • returnHeaders: If set to true, returns HTTP headers and status code. This also suppresses exceptions on HTTP error status codes, leaving this to the developer to handle.

var response = http.getUrl('https://api.example.com', {  
    format: 'json',  
    query: {    
        booleanAttribute: booleanAttribute,    
        name: name,    
        restaurantStyle: restaurantStyle,    
        address: address,    
        menuItem: menuItem  
    }
})
ํ€˜์ŠคํŠธ2. Bixby๋กœ ์ฃผ๋ณ€ ๋ง›์ง‘ ์ฐพ๊ธฐ

Last updated

Was this helpful?