React SPA application using for work with Valantis store API.
Run npm run start
for a dev server. Navigate to http://localhost:3000/
. The application will automatically reload if you change any of the source files.
Run ng generate c component-name
to generate a new component. You can also use ng generate directive|pipe|service|class|guard|interface|enum|module
.
Run npm run build
to build the project. The build artifacts will be stored in the dist/
directory.
Инструкция по запуску:
- Склонировать репозиторий -
git clone <repo name>
- Выполнить команду в консоли от корня приложения -
npm i
- Выполнить команду запуска приложения -
npm run start
- Перейти в Chrome на
http://localhost:3000/
- Чтобы проверить работоспособность пункта "Если API возвращает дубли по id, то следует их считать одним товаром и выводить только первый, даже если другие поля различаются" помимо видимого эффекта (отсутствия дублей) в самом ui можно перейти в файл
api.ts
к методуgetProductsIdsReq()
- там оставлен комментарий, указывающий на использование Set для ids, что убирает дубли. - Чтобы проверить работоспособность пункта "Если API возвращает ошибку, следует вывести идентификатор ошибки в консоль, если он есть и повторить запрос." в том же файле
api.ts
можно увидеть методapiWithRetries
в который оборачиваются методы апи. Используя циклwhile
и переменнуюretries
(кол-во повторений запроса по дефолту выставленное в знаечение1
) реализуют повторения запроса к серверу в случае ошибки указанное вretries
кол-во раз.
Start instructions:
- Clone the repository -
git clone <repo name>
- Run the command in the console from the root of the app -
npm i
- Run the app start command -
npm run start
- Go to Chrome to
http://localhost:3000/
- To check the functionality of the point "If the API returns duplicates by id, then res should be considered one product and output only the 1st one, even if the other fields differ" in addition to the visible effect (absence of duplicates) in the ui itself, you can go to the
api.ts
file to thegetProductsIdsReq()
method - there is a comment left indicating the use of Set for ids, which removes all duplicates. - To check the functionality of the point "If the API returns an error, you should output the error ID to the console, if there is one, and repeat the request." in the same
api.ts
file, you can see theapiWithRetries
method in which api methods are wrapped. Using thewhile
loop and theretries
variable (the number of repetitions of the request is set to1
by default), it implements the repetition of the request to the server in case of an error, the number of repetitions specified inretries
var.