You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

1.1 KiB

Instructions

Create the queryServers function, that takes 2 arguments:

  • serverName a string of the name of the server
  • q a string of the query given by the user

You have to construct 2 urls, using q as a search parameter, prepending a '/' and for the 2nd appending '_backup'.

Then return the first value of those 2 calls

queryServers('pouet', 'hello+world')
  // return the fastest of those 2 calls:
  // -> getJSON('/pouet?q=hello+world')
  // -> getJSON('/pouet_backup?q=hello+world')

Create a gougleSearch function that takes a single query argument. It must call queryServers in concurrently on 3 servers: 'web', 'image' and 'video'.

A timeout of 80milliseconds must be set for the whole operation.

You must return the value from each servers in an object using a the server name as key.

Notions

Code provided

// fake `getJSON` function
let getJSON = async (url) => url