Skip to content

Commit 0567a7a

Browse files
committed
feat: add retry strategy for api-rest category
1 parent 9df50a9 commit 0567a7a

File tree

6 files changed

+79
-31
lines changed

6 files changed

+79
-31
lines changed

src/pages/[platform]/build-a-backend/add-aws-services/rest-api/delete-data/index.mdx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ async function deleteItem() {
3737
try {
3838
const restOperation = del({
3939
apiName: 'myRestApi',
40-
path: 'items/1'
40+
path: 'items/1',
41+
retryStrategy: {
42+
strategy: 'no-retry'
43+
},
4144
});
4245
await restOperation.response;
4346
console.log('DELETE call succeeded');

src/pages/[platform]/build-a-backend/add-aws-services/rest-api/fetch-data/index.mdx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,12 @@ import { get } from 'aws-amplify/api';
3636
async function getItem() {
3737
try {
3838
const restOperation = get({
39-
apiName: 'myRestApi',
40-
path: 'items'
41-
});
39+
apiName: 'myRestApi',
40+
path: 'items'
41+
retryStrategy: {
42+
strategy: 'no-retry'
43+
},
44+
});
4245
const response = await restOperation.response;
4346
console.log('GET call succeeded: ', response);
4447
} catch (error) {

src/pages/[platform]/build-a-backend/add-aws-services/rest-api/post-data/index.mdx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ async function postItem() {
4242
body: {
4343
message: 'Mow the lawn'
4444
}
45-
}
45+
},
46+
retryStrategy: {
47+
strategy: 'no-retry'
48+
},
4649
});
4750

4851
const { body } = await restOperation.response;

src/pages/[platform]/build-a-backend/add-aws-services/rest-api/set-up-http-api/index.mdx

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -233,13 +233,22 @@ import outputs from '../amplify_outputs.json';
233233

234234
const amplifyConfig = parseAmplifyConfig(outputs);
235235

236-
Amplify.configure({
237-
...amplifyConfig,
238-
API: {
239-
...amplifyConfig.API,
240-
REST: outputs.custom.API,
236+
Amplify.configure(
237+
{
238+
...amplifyConfig,
239+
API: {
240+
...amplifyConfig.API,
241+
REST: outputs.custom.API,
242+
},
241243
},
242-
});
244+
{
245+
API: {
246+
retryStrategy: {
247+
strategy: 'no-retry'
248+
},
249+
},
250+
}
251+
);
243252
```
244253
</InlineFilter>
245254

@@ -251,13 +260,22 @@ import outputs from '@/amplify_outputs.json';
251260

252261
const amplifyConfig = parseAmplifyConfig(outputs);
253262

254-
Amplify.configure({
255-
...amplifyConfig,
256-
API: {
257-
...amplifyConfig.API,
258-
REST: outputs.custom.API,
263+
Amplify.configure(
264+
{
265+
...amplifyConfig,
266+
API: {
267+
...amplifyConfig.API,
268+
REST: outputs.custom.API,
269+
},
259270
},
260-
});
271+
{
272+
API: {
273+
retryStrategy: {
274+
strategy: 'no-retry'
275+
},
276+
}
277+
}
278+
);
261279
```
262280
</InlineFilter>
263281

src/pages/[platform]/build-a-backend/add-aws-services/rest-api/set-up-rest-api/index.mdx

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -216,13 +216,22 @@ import outputs from '../amplify_outputs.json';
216216

217217
const amplifyConfig = parseAmplifyConfig(outputs);
218218

219-
Amplify.configure({
220-
...amplifyConfig,
221-
API: {
222-
...amplifyConfig.API,
223-
REST: outputs.custom.API,
219+
Amplify.configure(
220+
{
221+
...amplifyConfig,
222+
API: {
223+
...amplifyConfig.API,
224+
REST: outputs.custom.API,
225+
},
224226
},
225-
});
227+
{
228+
API: {
229+
retryStrategy: {
230+
strategy: 'no-retry'
231+
},
232+
}
233+
}
234+
);
226235
```
227236
</InlineFilter>
228237

@@ -234,13 +243,22 @@ import outputs from '@/amplify_outputs.json';
234243

235244
const amplifyConfig = parseAmplifyConfig(outputs);
236245

237-
Amplify.configure({
238-
...amplifyConfig,
239-
API: {
240-
...amplifyConfig.API,
241-
REST: outputs.custom.API,
242-
},
243-
});
246+
Amplify.configure(
247+
{
248+
...amplifyConfig,
249+
API: {
250+
...amplifyConfig.API,
251+
REST: outputs.custom.API,
252+
},
253+
},
254+
{
255+
API: {
256+
retryStrategy: {
257+
strategy: 'no-retry'
258+
},
259+
}
260+
}
261+
);
244262
```
245263
</InlineFilter>
246264

src/pages/[platform]/build-a-backend/add-aws-services/rest-api/update-data/index.mdx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ async function updateItems() {
4141
path: 'items/1',
4242
options: {
4343
body: Item
44-
}
44+
},
45+
retryStrategy: {
46+
strategy: 'no-retry'
47+
},
4548
});
4649
const response = await restOperation.response;
4750
console.log('PUT call succeeded: ', response);

0 commit comments

Comments
 (0)