{"_id":"@avitus/svelte-request-helper","_rev":"7-d029d34a06785fea10969e2fa9022129","name":"@avitus/svelte-request-helper","dist-tags":{"latest":"1.0.0"},"versions":{"0.0.1":{"name":"@avitus/svelte-request-helper","version":"0.0.1","author":{"name":"Christoffer Lundberg","email":"christoffer@avitusit.se","url":"https://avitusit.se"},"description":"A svelte compatible request helper for SSR and client requests to reduce boilerplate code","repository":{"type":"git","url":"git+https://github.com/christoffer_one/svelte-request-helper.git"},"main":"index.js","keywords":["svelte","request","helper"],"license":"MIT","dependencies":{"lodash":"^4.17.21"},"bugs":{"url":"https://github.com/christoffer_one/svelte-request-helper/issues"},"homepage":"https://github.com/christoffer_one/svelte-request-helper#readme","_id":"@avitus/svelte-request-helper@0.0.1","_nodeVersion":"14.13.1","_npmVersion":"6.14.8","dist":{"integrity":"sha512-yyE74PnuLg13qxfcXP/G1zSoCV1bn3DIn1OXD2fwwPsyiQJQ+f4r2/olV1aDnSuzs3jTWcdwctJfOsM+iaB32w==","shasum":"160a8e7b649ff06c98f4e2449d617cc40a30392c","tarball":"https://registry.npmjs.org/@avitus/svelte-request-helper/-/svelte-request-helper-0.0.1.tgz","fileCount":4,"unpackedSize":4471,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDWQjpuy9W0yHb4WeY+HOnIfugKehLAbB097X0QlE9QzgIgeF01Rsqayo7pdgJmVEJsNtCSBW05p3knpEjZXjZgqVg="}]},"_npmUser":{"name":"christoffer_one","email":"christoffer@avitusit.se"},"directories":{},"maintainers":[{"name":"christoffer_one","email":"christoffer@avitusit.se"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/svelte-request-helper_0.0.1_1636558667179_0.009273509312311967"},"_hasShrinkwrap":false},"0.0.2":{"name":"@avitus/svelte-request-helper","version":"0.0.2","author":{"name":"Christoffer Lundberg","email":"christoffer@avitusit.se","url":"https://avitusit.se"},"description":"A svelte compatible request helper for SSR and client requests to reduce boilerplate code","repository":{"type":"git","url":"git+https://github.com/christoffer_one/svelte-request-helper.git"},"main":"index.js","keywords":["svelte","request","helper"],"license":"MIT","dependencies":{"lodash":"^4.17.21"},"bugs":{"url":"https://github.com/christoffer_one/svelte-request-helper/issues"},"homepage":"https://github.com/christoffer_one/svelte-request-helper#readme","_id":"@avitus/svelte-request-helper@0.0.2","_nodeVersion":"14.13.1","_npmVersion":"6.14.8","dist":{"integrity":"sha512-I7+dp+pFNfuPhCGNKYNQni36HyAEYUg4Njw3Jo1xh3b1OWhDFkMbYk4yCOyym57A4YaMIq5d0+dhIav5U3vN0A==","shasum":"6fca0ad7874bb6afbee09603951565747271b139","tarball":"https://registry.npmjs.org/@avitus/svelte-request-helper/-/svelte-request-helper-0.0.2.tgz","fileCount":4,"unpackedSize":6442,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDZFJ4knNuf6rZDeTygtkfW4Y08NHlW8w8AHV7GDfXoZAiA37zkYN7ek7u9TjqZdwOYzf4FRL9Y1z/1PUuOld4pz/Q=="}]},"_npmUser":{"name":"christoffer_one","email":"christoffer@avitusit.se"},"directories":{},"maintainers":[{"name":"christoffer_one","email":"christoffer@avitusit.se"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/svelte-request-helper_0.0.2_1636562339722_0.899174076423026"},"_hasShrinkwrap":false},"0.0.3":{"name":"@avitus/svelte-request-helper","version":"0.0.3","author":{"name":"Christoffer Lundberg","email":"christoffer@avitusit.se","url":"https://avitusit.se"},"description":"A svelte compatible request helper for SSR and client requests to reduce boilerplate code","repository":{"type":"git","url":"git+https://github.com/avitus/svelte-request-helper.git"},"main":"index.js","keywords":["svelte","request","helper"],"license":"MIT","dependencies":{"lodash":"^4.17.21"},"bugs":{"url":"https://github.com/avitus/svelte-request-helper/issues"},"homepage":"https://github.com/avitus/svelte-request-helper#readme","_id":"@avitus/svelte-request-helper@0.0.3","_nodeVersion":"14.13.1","_npmVersion":"6.14.8","dist":{"integrity":"sha512-JTfhnRELq3Mrlf5ywjAnBQ7CP8CXtRRHU+hc7hpsuh3pqAWKmh+XJw0IXNVoEA62vtQFTsAOibokwsQ2PGV6wg==","shasum":"21034b5defa0ab33e8c69635cdbf9b4818bc64ef","tarball":"https://registry.npmjs.org/@avitus/svelte-request-helper/-/svelte-request-helper-0.0.3.tgz","fileCount":4,"unpackedSize":6433,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCxJH+wcXW/7HDMzzk0h1bhmyXKEbAvvZ1i7Jez4U3cxgIgEti7orsES+jDYAcB2X6Fl7LAkgWkOR32irAF9jz4tgA="}]},"_npmUser":{"name":"christoffer_one","email":"christoffer@avitusit.se"},"directories":{},"maintainers":[{"name":"christoffer_one","email":"christoffer@avitusit.se"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/svelte-request-helper_0.0.3_1636562516555_0.8345054380125385"},"_hasShrinkwrap":false},"0.0.4":{"name":"@avitus/svelte-request-helper","version":"0.0.4","author":{"name":"Christoffer Lundberg","email":"christoffer@avitusit.se","url":"https://avitusit.se"},"description":"A svelte compatible request helper for SSR and client requests to reduce boilerplate code","repository":{"type":"git","url":"git+https://github.com/avitus/svelte-request-helper.git"},"main":"index.js","keywords":["svelte","request","helper"],"license":"MIT","dependencies":{"lodash":"^4.17.21"},"bugs":{"url":"https://github.com/avitus/svelte-request-helper/issues"},"homepage":"https://github.com/avitus/svelte-request-helper#readme","_id":"@avitus/svelte-request-helper@0.0.4","_nodeVersion":"14.13.1","_npmVersion":"6.14.8","dist":{"integrity":"sha512-Cd7kt8mQTb2AESNeSiDdu05X8JPlJenC4CTagx4eACOuPwstgX7zVx25H4EKfwnvKIpyJDgyRBOTI8t93EPqDQ==","shasum":"04fe4ad1bf837696c3ef3129573c1727f9729f3b","tarball":"https://registry.npmjs.org/@avitus/svelte-request-helper/-/svelte-request-helper-0.0.4.tgz","fileCount":4,"unpackedSize":6398,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBsg62kVOsahhSy2d/+Oxk66CKujP+WZQ3pVs811bZHRAiEAhziwDb7Jy0/U8QfRiQRYQUT3Gn21Uz/rOUUE+fsZYzc="}]},"_npmUser":{"name":"christoffer_one","email":"christoffer@avitusit.se"},"directories":{},"maintainers":[{"name":"christoffer_one","email":"christoffer@avitusit.se"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/svelte-request-helper_0.0.4_1636562576832_0.007238752730112319"},"_hasShrinkwrap":false},"0.0.5":{"name":"@avitus/svelte-request-helper","version":"0.0.5","author":{"name":"Christoffer Lundberg","email":"christoffer@avitusit.se","url":"https://avitusit.se"},"description":"A svelte compatible request helper for SSR and client requests to reduce boilerplate code","repository":{"type":"git","url":"git+https://github.com/avitus/svelte-request-helper.git"},"main":"index.js","keywords":["svelte","request","helper"],"homepage":"https://gitlab.com/avitusit/svelte-request-helper","license":"MIT","dependencies":{"lodash":"^4.17.21"},"gitHead":"6b5b39bd3f8291216a207ef4632e3ea8ee16100d","bugs":{"url":"https://github.com/avitus/svelte-request-helper/issues"},"_id":"@avitus/svelte-request-helper@0.0.5","_nodeVersion":"14.13.1","_npmVersion":"6.14.8","dist":{"integrity":"sha512-ufAFmPsiWw3DSfj+wsjAV1jB4vcx1p5JLPKG94zN2D0M/R6cAuMnPGcwHgHzKWNpELEYewmCPiQHG8FgSzZ6oQ==","shasum":"ff9c0a6eeb53bee7e0c8c7a4679663310f5a24ba","tarball":"https://registry.npmjs.org/@avitus/svelte-request-helper/-/svelte-request-helper-0.0.5.tgz","fileCount":4,"unpackedSize":8729,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGlnuQrAl/+u4X70wKRdEaKsZFAJoWcQ7sSUO9MbkQ/pAiEAxwFV2PbOKkPMO8iyeXkhmc8l8hrub2MMyJMIqJdWhD4="}]},"_npmUser":{"name":"christoffer_one","email":"christoffer@avitusit.se"},"directories":{},"maintainers":[{"name":"christoffer_one","email":"christoffer@avitusit.se"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/svelte-request-helper_0.0.5_1636622293356_0.6446982740699472"},"_hasShrinkwrap":false},"1.0.0":{"name":"@avitus/svelte-request-helper","version":"1.0.0","author":{"name":"Christoffer Lundberg","email":"christoffer@avitusit.se","url":"https://avitusit.se"},"description":"A svelte compatible request helper for SSR and client requests to reduce boilerplate code","repository":{"type":"git","url":"git+https://gitlab.com/avitusit/svelte-request-helper.git"},"main":"index.js","keywords":["svelte","request","helper"],"homepage":"https://gitlab.com/avitusit/svelte-request-helper","license":"MIT","dependencies":{"lodash":"^4.17.21"},"gitHead":"6b5b39bd3f8291216a207ef4632e3ea8ee16100d","bugs":{"url":"https://gitlab.com/avitusit/svelte-request-helper/issues"},"_id":"@avitus/svelte-request-helper@1.0.0","_nodeVersion":"14.13.1","_npmVersion":"6.14.8","dist":{"integrity":"sha512-IVJ9z2VYHHPcaHrJ7Ja9pivqnvVzJ434lCGLu6SFEOdR33g6RcsY9R51dMBUsFzagTVXUEwe6ww2+Yc+NRPnRA==","shasum":"1b219739deb6532dda01113cb863fe8e5b6ae3ff","tarball":"https://registry.npmjs.org/@avitus/svelte-request-helper/-/svelte-request-helper-1.0.0.tgz","fileCount":4,"unpackedSize":8750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh12LQCRA9TVsSAnZWagAAZ8sP/1Qhmbc5XRUMkIpbGV3/\n3sh/gleon7YPOBWohBQ3KWn5Jm0pYEOTVIqDI/RLt/vPqJCKcebvxULQ+9ay\np0GeEYNEmgbAJa9hTeSltVZZC/b3IwIj64fKUfM21Td99lRHwYVpUlawRZGL\nF4hc0bTNOLPjqeoDhLxdd7r7fWZVad+1ilFlzarQ5I8AlP9AtQX0HyXXvm/6\nH060HPxffzbiAJ+SAgBH9MSFdj/wwclih5PqOZEjR3M5mXa5npZCzIdGEFTO\nOG+n8pXkzB1lF8b4PHVD6R9Zm7u5VgQ+41RQYI8IjoS78hMWEGBN9SGyNfcZ\nWD4gM0ZEM3To9Xno+5mqh5e/enO9Hl1rkLL+9EJbrmoCc3XwfjAzIx3h84wg\n6IPt5AEqnhGmPGmXRO9jQYXaGetE9aamXE18I/j1WXdpdrOnS7YxqFhnCqFb\n9LaJgRdd9o06hUlUE2TRGNFIskcv5AXtn3dN/YVtAO8BDB+szSAshEpqv5nt\n6QDtSTUHF329xRyso/Bpx++4RL0LYxIZth4gO5xrSX3/M5SCWzSvTnAd63ex\nVVSw95WSyq9uGnC8BGQ3lFnE2FHTvxY4j9/ge5SIoq3lvt/Jamys8y+o7EZv\n3q0K7B8JhI5kZyBuQ/i7HjtIHdjkjBOH6N9pMTPb9o5NwgZbek055NWczZem\nl6x+\r\n=C2H8\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCmISH3LHbTYr0OFss6oa398ltDWhW9leknOSgpiL82iwIgRwG50JeM/q7YyZ8L5D/sxLMbbDa5MXko2ZaSGakHFaI="}]},"_npmUser":{"name":"christoffer_one","email":"christoffer@avitusit.se"},"directories":{},"maintainers":[{"name":"christoffer_one","email":"christoffer@avitusit.se"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/svelte-request-helper_1.0.0_1636622335236_0.21666585050677178"},"_hasShrinkwrap":false}},"time":{"created":"2021-11-10T15:37:47.133Z","0.0.1":"2021-11-10T15:37:47.319Z","modified":"2022-04-04T16:47:50.597Z","0.0.2":"2021-11-10T16:38:59.977Z","0.0.3":"2021-11-10T16:41:56.722Z","0.0.4":"2021-11-10T16:42:56.969Z","0.0.5":"2021-11-11T09:18:13.493Z","1.0.0":"2021-11-11T09:18:55.396Z"},"maintainers":[{"name":"christoffer_one","email":"christoffer@avitusit.se"}],"description":"A svelte compatible request helper for SSR and client requests to reduce boilerplate code","homepage":"https://gitlab.com/avitusit/svelte-request-helper","keywords":["svelte","request","helper"],"repository":{"type":"git","url":"git+https://gitlab.com/avitusit/svelte-request-helper.git"},"author":{"name":"Christoffer Lundberg","email":"christoffer@avitusit.se","url":"https://avitusit.se"},"bugs":{"url":"https://gitlab.com/avitusit/svelte-request-helper/issues"},"license":"MIT","readme":"# @avitus/svelte-request-helper\n\n[![npm (scoped)](https://img.shields.io/npm/v/@avitus/svelte-request-helper.svg)](https://www.npmjs.com/package/@avitus/svelte-request-helper)\n[![npm bundle size (minified)](https://img.shields.io/bundlephobia/min/@avitus/svelte-request-helper.svg)](https://www.npmjs.com/package/@avitus/svelte-request-helper)\n\n## Install\n\n```\n$ npm install @avitus/svelte-request-helper\n```\n\n## Usage\n\n### Making SSR requests\n\nTo make request from the `\"module\"` context simply import the request helper and return its response from your `load` function. The request helper will make sure to return a format compatible with the response of svelte load function response.\n\nA basic request consists of an object with two keys:\n- url – The request URL\n- key – The key specifies to which exported variable the response should assigned\n\n_Note:_ The first argument for the request helper is `fetch`, this is required to have SvelteKit use the correct instance of fetch in SSR, this should **ALWAYS** be included when using the request helper from the module context.\n\n```js\n<script context=\"module\">\n    import Request from \"@avitus/svelte-request-helper\";\n\n    export async function load({ fetch }) {\n        return Request(fetch, [\n            {\n                key: 'foo',\n                url: '/api/foo/bar',\n            }\n        ])\n    }\n</script>\n```\n\nThe response from a request is then put into and exported let with the name of the key. A second variable is also populated automatically if an error occurs during the request. The error variable is simple the name of the key followed by `error`.\n\n```js\n<script>\n    export let foo = []\n    export let fooError = null\n</script>\n```\n\n### Multiple requests\n\nThe request helper can send multiple SSR requests simply by adding multiple request blocks to the requests array like so:\n\n```js\n<script context=\"module\">\n    import Request from \"@avitus/svelte-request-helper\";\n\n    export async function load({ fetch }) {\n        return Request(fetch, [\n            {\n                key: 'foo',\n                url: '/api/foo',\n            },\n            {\n                key: 'bar',\n                url: '/api/bar',\n            },\n            {\n                key: 'baz',\n                url: '/api/baz',\n            },\n        ])\n    }\n</script>\n```\n\n```js\n<script>\n    export let foo = []\n    export let fooError = null\n\n    export let bar = []\n    export let barError = null\n\n    export let baz = []\n    export let bazError = null\n</script>\n```\n\n### Single requests\n\nWhen using the request helper for single request the requests array can be switched out for a single request object instead. Also if the request is not intended to be executed server side the `fetch` argument can simply be omitted.\n\n```js\nconst response = await Request({\n    method: 'post',\n    url: '/api/login',\n    data: {\n        username: username,\n        password: password,\n    }\n})\n\nif (response.ok) {\n    console.log('Icecream for everyone!')\n}\n```\n\n### Options\n\nRequest blocks can also include a range of different options listed below:\n- method – (String) Specify HTTP method to use for request\n- data - (Object) Optional body to include in request\n- optional – (Bool) Allow request to fail\n- dependency – (String) Use previous request response value in next request\n\n#### Method\n```Default = 'GET'```\n<br>\nSpecify HTTP method to use for request\n\n#### Data\n```Default = null```\n<br>\nSpecify a request body for the request. This will be converted to a JSON string automatically before the request is sent.\n\n#### Optional\n```Default = false```\n<br>\nSets whether to allow the specific request block to fail or not. If a request that is not optional fails it will fail the whole pipeline and return an error.\n\n#### Dependency\n```Default = null```\n<br>\nThe dependency can be used if a request is dependent of the result of a previous request.\nWhat previous request to take the response from and what value from the response to use is specified as a string starting with the key name of the dependency request followed with a path to the value in question.\nE.g. `myKey.foo.id`.\nIf the dependency value is not present this request will yield an error.\nThe dependency value is automatically appended to the end of the request URI.\n\n##### Example\n```js\n<script context=\"module\">\n    import Request from \"@avitus/svelte-request-helper\";\n\n    export async function load({ fetch }) {\n        return Request(fetch, [\n            {\n                key: 'foo',\n                url: '/api/foo',\n            },\n            {\n                key: 'bar',\n                url: '/api/bar/', /* The dependency value will be appended to the end of this URI */\n                dependency: 'foo.id',\n            },\n        ])\n    }\n</script>\n```\n","readmeFilename":"README.md"}